...

View Full Version : Resizing according to screen dimensions



Jacka
06-13-2007, 10:40 PM
I've made a script to resize certain elements of my page according to how much of the window is available.

It uses absolute positioning.


function resize(){
var height=document.documentElement.clientHeight;
var width=document.documentElement.clientWidth;

document.getElementById('spare').style.height=(height-32)+"px";
document.getElementById('spare').style.width=(width-767)+"px";
}

I'm getting this error.


document.getElementById("spare") has no properties
.../script.js
Line 26

The element is an iframe, and if needed I can provide more code, but in the meantime, I'm getting some kip!

Thanks for reading this thread, farewell.

glenngv
06-13-2007, 11:05 PM
Does the iframe have an id of "spare"?

Jacka
06-14-2007, 10:28 AM
Yes.


<iframe src="blank.html" id="spare" frameborder="0" style="position:absolute; bottom:0px; right:0px;"></iframe>

Jacka
06-14-2007, 11:09 AM
The element does exist once the page has loaded, so I think that when resize(); is called onload, the iframe hasn't been created yet, so has no properties.

Would this me likely?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum