This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Expanding Iframes


  1. Dmaxon
    Member

    Hello, I'm currently using exanding iframes in my site but the ones that expand, expands in both up and down (not width)
    Is there anyway to make it expand only downwards because it looks a bit silly when my header moves upwards just by going into another iframe.

    <script type="text/javascript">

    /***********************************************
    * IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
    * Visit DynamicDrive.com for hundreds of original DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/

    //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
    //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
    var iframeids=["myframe"]

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

    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;
    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>

    Posted 15 years ago #
  2. redityo

    Have you try the script that posted in here ?

    http://www.appnitro.com/forums/topic/auto-expandadjustable-iframe?replies=21


    MachForm Support

    Posted 15 years ago #
  3. Dmaxon
    Member

    I have tryed it but when I press a link that goes to my iframe, it pops up in a new window, not sure why...
    wouldnt that do the same thing tho?

    Posted 15 years ago #
  4. redityo

    The script in that post should auto expand the iframe only. Anyway, is it possible to send me your url in here ? Otherwise you can send it to :

    customer.service[at]appnitro.com


    MachForm Support

    Posted 15 years ago #
  5. Dmaxon
    Member

    you know , I decided not to care about it to much but it would be nice if I could make the header in a absolute position somehow.
    http://www.victorbergsten.se is the link and you can see what I mean by going to the "senaste nytt" button , this problem only seem to be firefox tho.

    Posted 15 years ago #

RSS feed for this topic

Reply