Results 1 to 4 of 4

Thread: [DHTML] iFrame SSI Code III

  1. #1
    Join Date
    Jan 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool [DHTML] iFrame SSI Code III

    iFrame SSI Code III

    Based on iFrame SSI Code II (by Dynamic Drive)

    Alows you to resize an iFrame to the size of the content.

    Diffrences from iFrame SSI Code II:

    • Option to not execute Code if it's unsupported (no_execute mode).
    • Option to resize iFrame every x seconds (use null to disable).
    • This version dosn't execute by itself you need to call the following Javascript (preferbly in the body onload atribute), "callresize(refreshtime)" .



    Code:
    <script type="text/javascript">
    
    /***********************************************
    * IFrame SSI script III- © Dynamic Drive DHTML code library and Madcow (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=["myiFrame"]
    
    //Should script hide iframe from browsers that don't support this script:
    // Use value "no_execute" to not execute when script is unsupported (Recomended).
    var iframehide="no_execute"
    
    // set height of iFrame for unSupported Browsers
    var unsupportedheight = 550;
    
    //Time before it resizes iFrame. Enter null to disable this.
    var refreshtime=100;
    
    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+30; 
    else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
    currentfr.height = currentfr.Document.body.scrollHeight+30;
    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
    }
    
    function callresizecaller(time){
    resizeCaller()
    callresize(time)
    }
    function callresize(time){
    if ((document.all || document.getElementById) && iframehide == "no_execute"){
    if (time != null){
    var t = setTimeout("callresizecaller("+time+")",time);
    }else{
    resizeCaller()
    }
    }
    }
    
    </script>

  2. #2
    Join Date
    Jan 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What do people think?

  3. #3
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    nice

  4. #4
    Join Date
    Jan 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks

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
  •