Web Analytics Made Easy -
StatCounter if src changes the style must change to - CodingForum

Announcement

Collapse
No announcement yet.

if src changes the style must change to

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • if src changes the style must change to

    Hi im a newbie to java so please don't laugh. And apologies in advance for my English.

    When i open my page the src of the iframe is home.html. Home.html is empty and its in the way of the interface of my .swf file. My swf triggers the iframe to change into 50 different URL. So at the beginning the iframe should be gone. But whenever the src changes it should come back. I tried it by changing the height of the iframe. But nothing changes.

    here is a preview http://boyswithbeards.net/xrc/pres/

    I have something like this.




    <iframe name="MoinkOriginal" id="MoinkOriginal" src="home.html" frameborder="0" scrolling="auto"></iframe>


    <script type = "text/javascript">
    var iframe = document.getElementById('MoinkOriginal');

    if (src='home.html') {

    var iframeElement = parent.document.getElementById('MoinkOriginal');
    iframeElement.style.height = "0px"; // or use px
    iframeElement.style.width = "500px"; // or use px
    iframeElement.style.marginHeight = "-563px"; // or use px
    iframeElement.style.marginLeft = "750px"; // or use px

    }

    else {

    var iframeElement = parent.document.getElementById('MoinkOriginal');
    iframeElement.style.height = "300px";
    iframeElement.style.width = "500px";
    iframeElement.style.marginHeight = "-563px"; // or use px
    iframeElement.style.marginLeft = "750px"; // or use px
    }

    </script>


    Thank you for helping me. Im stuck on this for days.

  • #2
    there is no margin-height CSS style ... it should be marginTop and/or marginBottom

    Comment


    • #3
      Oke I have changed that. But it is still not solving my problem to let the size of the iframe change as the src changes.

      <script type = "text/javascript">


      var iframe = document.getElementById('MoinkOriginal');

      if (src='home.html') {


      var iframeElement = parent.document.getElementById('MoinkOriginal');
      iframeElement.style.height = "10px";
      iframeElement.style.width = "500px";
      iframeElement.style.marginTop = "-563px";
      iframeElement.style.marginLeft = "750px";

      }

      else {

      var iframeElement = parent.document.getElementById('MoinkOriginal');
      iframeElement.style.height = "300px";
      iframeElement.style.width = "500px";
      iframeElement.style.marginTop = "-0px";
      iframeElement.style.marginLeft = "750px";
      }

      </script>

      Comment


      • #4
        One problem after the other

        1. What is the variable "src" referring to? It's not mentioned anywhere
        2. The compare operator is == and not =

        I think this is what you really wanted to do
        Code:
        if(iframe.src == 'home.html')
        3. You should alert iframe.src to make sure that it is just home.html and not a fully qualified URL instead (so maybe everything including http://www.........)

        Comment


        • #5
          Thankx devnull

          the http:// worked. At this point when i enter the page he listens to the code top side of the code.

          But i think the problem is that tha page only listens once to the code and doesnt reload and check what the src is

          is this possible and is there a way that the code keeps looping in order to see what the src is?

          Comment


          • #6
            I think I need something that triggers the java again when the source reloads

            now I have this:

            var iframe = document.getElementById('MoinkOriginal');
            iframe.onload = iframehandler;
            function iframehandler()
            { etc.

            but it still doesnt reload.

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎