Results 1 to 8 of 8

Thread: iframe-Javascript combination doesnt work in Firefox

  1. #1
    Join Date
    Aug 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default iframe-Javascript combination doesnt work in Firefox

    Hi all

    My page:

    http://www.nitishbelut.com/indymoviemakers/index.html

    My problem:

    I use two iframes one above the other( header + content).However, the iframe's (content) height was not adjusting to the length of the page inside it.So i used javascript (i got somewhere from the net) to automatically resize the height of the iframe.It works fine with I.E but the iframe doesnt get displayed in Firefox at all. View the page in I.E and in F.F to better understand the problem.

    Can anyone tell me how to solve this problem.Below is the javascript code.

    Thanks

    <script type="text/javascript">

    var iframeids=["content"]

    //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
    var iframehide="no"

    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
    var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

    function resizeCaller() {
    var dyniframe=new Array()
    for (i=0; i<iframeids.length; i++){
    if (document.getElementById)
    resizeIframe(iframeids[i])
    //reveal iframe for lower end browsers? (see var above):
    if ((document.all || document.getElementById) && iframehide=="no"){
    var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
    tempobj.style.display="block"
    }
    }
    }

    function resizeIframe(frameid){
    var currentfr=document.getElementById(frameid)
    if (currentfr && !window.opera){
    currentfr.style.display="block"
    if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
    currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
    else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
    currentfr.height = currentfr.Document.body.scrollHeight+20;
    if (currentfr.addEventListener)
    currentfr.addEventListener("load", readjustIframe, false)
    else if (currentfr.attachEvent){
    currentfr.detachEvent("onload", readjustIframe) // Bug fix line
    currentfr.attachEvent("onload", readjustIframe)
    }
    }
    }

    function readjustIframe(loadevt) {
    var crossevt=(window.event)? event : loadevt
    var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
    if (iframeroot)
    resizeIframe(iframeroot.id);
    }

    function loadintoIframe(iframeid, url){
    if (document.getElementById)
    document.getElementById(iframeid).src=url
    }

    if (window.addEventListener)
    window.addEventListener("load", resizeCaller, false)
    else if (window.attachEvent)
    window.attachEvent("onload", resizeCaller)
    else
    window.onload=resizeCaller
    </script>

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Us percentages!! It's very useful

    set the global padding and margin to 0px:

    Code:
    <style type="text/css">
    * {
    padding:0px;
    margin:0px
    }
    </style>
    Ex:

    Code:
    <iframe width="25%" height="100%"></iframe>
    <iframe width="75%" height="100%"></iframe>
    - Mike

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    nitish -

    First off, that is a Dynamic Drive script (and varies ever so slightly from what you have in your post, this one difference could be important):

    http://www.dynamicdrive.com/dynamici...iframessi2.htm

    Please restore the credit:

    Your page is in violation of Dynamic Drive's usage terms, which, among other things, state that the script credit must appear in the source code of the HTML page(s) using the script. Please reinstate the notice first.


    Second, you really need to apply it to both iframes (if they both can vary in the size of their loaded content).

    Also, make sure that you read, understand and follow all the installation instructions on the demo page (linked to above). If you still are having problems, get back to us.

    mburt -

    I am curious. Did you test out this theory of yours on this particular problem? Or, is this just a case of a child with a new toy hammer suddenly thinking that everything needs hammering?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Percentages automatically reset the page width and height to the screen resolultion. It's very helpful.
    - Mike

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by mburt
    Code:
    <iframe width="25%" height="100%"></iframe>
    <iframe width="75%" height="100%"></iframe>
    100% of what?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Aug 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the replies.

    It works now...but the display is horrible..looks like the CSS 'scrollbar' attributes are not working.I'll try to solve the different display problems as much as i can and get back to the forum as soon as i need more help.

    Also, I added the credit in the source code Didnt realise i had got the javascipt from Dynamic Drive!

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    John:
    100% of what?
    100% of the page height.
    - Mike

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It doesn't always work out that way.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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