Hey guys, im looking to dynamically resize an iframe to fit properly into a
page without scrolling. The iframe height is different page to page so the
iframe needs to be able to get bigger or smaller. Theres a thread over on
the  http://drupal.org/node/180625 Drupal forums  with the following code
that claims to resize the iframe but unfortunetly we've not been able to get
it to work.

Does this code work or is there a better way to do it?

We want to resize other websites pages so theres the cross domain security
issue but im assuming jquery can bypass this by retrieving the full page,
manipulating it and then displaying it.

We've been stuck on this problem for awhile now so any input would be great.


function doIframe(){
o = document.getElementsByTagName('iframe');
for(i=0;i<o.length;i++){
if (/\bautoHeight\b/.test(o[i].className)){
setHeight(o[i]);
addEvent(o[i],'load', doIframe);
}
}
}

function setHeight(e){
if(e.contentDocument){
e.height = e.contentDocument.body.offsetHeight + 35;
} else {
e.height = e.contentWindow.document.body.scrollHeight;
}
}

function addEvent(obj, evType, fn){
if(obj.addEventListener)
{
obj.addEventListener(evType, fn,false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}

if (document.getElementById && document.createTextNode){
addEvent(window,'load', doIframe);
}


-- 
View this message in context: 
http://www.nabble.com/Resizing-iframe-tf4730424s27240.html#a13526216
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to