In my web page I've the following javascript function that is called onLoad in the body:
function changeDivWidth()
{
d = document.getElementById('background');
document.getElementById("backgroundImg").style.height = window.innerHeight+"px";
imgWidth = document.getElementById("backgroundImg").width;
marginLeft = ($(window).width() - imgWidth)/2;
d.style.width = imgWidth+"px";
d.style.left = marginLeft+"px";
document.getElementById("backgroundImg").style.visibility="visible";
document.getElementById("menu").style.visibility="visible";
}
This script basically takes the height of the browser page and set it as height of an Element. This is working pretty fine in all browser except in IE7 and IE8, where the script is not loaded. Can you suggest me a solution?
Thanks
window.innerHeight
doesn't work in IE8 and below. Try out document.body.clientHeight
Edit: Wait a minute... are you using jQuery on line 6?:
marginLeft = ($(window).width() - imgWidth)/2;
If you are, then use $(window).height()
to get the height instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.