Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Auto resizing iframe


Go to End


1418 Views

Avatar
SerenityIT

Community Member, 13 Posts

6 May 2011 at 3:45am

Hi guys,

I'm trying to implement an auto resizing iframe into a page, but it requires to bits of script.

First bit (which I stuck in Page.ss):

<script language="JavaScript">
<!--
function autoResize(id){
var newheight;
var newwidth;

if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
}

document.getElementById(id).height= (newheight) + "px";
document.getElementById(id).width= (newwidth) + "px";
}
//-->
</script>

And the second bit:

<IFRAME SRC="../helpdesk" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"> </iframe>

Now the problem I run into, is the fact the CMS html editor strips out the onLoad="autoResize('iframe1'); bit from the code.

Plus on top of that, its a bit of a messy way to do it anyway as the top java loads on every page.

Any ideas on how I can successfully implement it? Otherwise I'll go back to my other idea of stripping the already loaded html code from the browser and building a page around that (resulting in my navigation not updating)