The code that i am working on is this-
var winW;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
}
if (winW = 1265) {
function setPosition()
{
document.getElementById("wblogo").style.left="1050px";
}
}
The code works perfectly when i use it with the onload
event in the body
tag.
But i want to use this when the page is being loaded. So i used the following code-
var winW;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
}
if (winW = 1265) {
document.getElementById("wblogo").style.left="1050px";
}
But this code doesn't work. Please help.