View Full Version : [DHTML] iFrame SSI Code III

01-12-2008, 03:56 PM
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)" .

<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){
//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])

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
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)

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

function callresizecaller(time){
function callresize(time){
if ((document.all || document.getElementById) && iframehide == "no_execute"){
if (time != null){
var t = setTimeout("callresizecaller("+time+")",time);


03-21-2008, 01:15 PM
What do people think?

04-08-2008, 03:59 PM
nice :)

05-18-2008, 01:53 PM