iFrames

css , javascript Belgium
  • 12 years ago

    I have an assignement to make a website that's compatible to both IE and FF. Because I am using an iFrame in a DIV, I use the following script to make sure the iFrame get's the right size:

                    window.onload = function()    {
                    var iframe = parent.document.getElementsByTagName('iframe')[0];
                    var h = document.body.offsetHeight + 200;
                    iframe.height = h;
                    }

    I also use a CSS stylesheet, where all the properties of my iFrame are stored. One of those properties is 'border', it's set to '0' and this works fine in FF but not in IE. So after some research I found out, IE doesn't support this, so I added 'frameborder="0"' to the HTML code. The borders are gone but now my JS is not working anymore in both browsers.

     
    A little help on this weird item is wanted

     
    Arne
     

  • 12 years ago

    Hi Arne - that sounds strange! Can I ask - is there any reason you need to use the javascript at all? Can you not just set the IFrame height in your stylesheet?

  • 12 years ago

     I tried that, but sometimes it doesn't work that well. I got the JS from someone on DevFusion and it seems to do the trick so ... :)

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov