Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 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
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    there is no margin-height CSS style ... it should be marginTop and/or marginBottom

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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>

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    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.........)

  • Users who have thanked devnull69 for this post:

    maxvanbakel (08-31-2011)

  • #5
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

  • #6
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •