...

View Full Version : Is window maximized ?



BubikolRamios
11-03-2007, 07:46 PM
Need to know for IE, would do no harm if there is a kode for FF allso :)

Found and lost solution on forum (but did not work anyway), so any help welcome.

Philip M
11-03-2007, 08:56 PM
http://www.codingforums.com/showthread.php?t=101285

BubikolRamios
11-04-2007, 05:42 PM
This works for FF and IE 7, howewer it is not 100% bullet proof, because user can manualy resize window to the dimensions that then returns true. But this is highly unlikely i.e almost inpossible.

If anyone can test this on IE 6.0 .... Thanks.




function isWindowMaximized()
{

if (window.outerHeight != null)
{
//FF
if (screen.width - window.outerWidth == -8)
{
//alert('FF');
return true;
}
}
else
{
//IE 7.0
if (screen.width -document.body.clientWidth == 4)
{
//alert('IE');
return true;
}

}

return false;
}

Philip M
11-05-2007, 09:19 AM
I tried it in IE 5.5 and get when maximised:

screen.width 1024
document.body.clientWidth 1002

felgall
11-05-2007, 09:59 PM
Of course all of those tests are assuming that there are no vertical toolbars on the desktop as if there were the maximized size would need to deduct the width of the toolbars.

BubikolRamios
11-06-2007, 02:30 AM
Apart from vertical tool bars, which I have newer seen jet .....

Philip, could you test that (save as html). In ie document.body.clientWidth gets influenced by 'SCROLL=NO'. I presume you should get '4px', or something, from below example when maximized.

Is there a way to detect 'SCROLL=NO' from java script ?
Does 'SCROLL=NO' equals style='overflow:hidden' ?



<html>
<head>
<SCRIPT language="javascript" type="text/javascript" >

function isMaximized()
{

if (navigator.appVersion.indexOf('MSIE 7.0') > 0)
{
alert('IE 7.0')
}

document.getElementById('testDiv').innerHTML = screen.width -document.body.clientWidth;
}
</SCRIPT>
</head>
<body SCROLL=NO class = 'body' onresize = 'isMaximized()'>
<div id="testDiv" style = 'float:left;width:100%;background-color:red;'>
s
</div>
</body>
</html>

BubikolRamios
11-06-2007, 05:03 AM
Just tested it in IE 6, and returns 4 px, so probably the same on all versions of IE. What remains is question of SCROLL=NO, and posibly vertical scroll bars problem...

BubikolRamios
11-07-2007, 12:12 AM
This should do it for FF and IE. Comments welcome.




function isMaximized()
{

if (window.outerHeight != null)
{
//FF
if((document.getelementsbytagname('body').style.overflow = 'scroll') && (screen.width - window.outerWidth == 17))
{
//alert('FF');
return true;
}
else if (screen.width - window.outerWidth == -8)
{
//alert('IE');
return true;
}
}
else
{
//IE 7.0
if (document.body.scroll = 'no')
{
//alert('IE');
return true;
}
else if((document.getelementsbytagname('body').style.overflow = 'scroll') && (screen.width - window.outerWidth == 21))
{
//alert('FF');
return true;
}
else if (screen.width - document.body.clientWidth == 4)
{
//alert('IE');
return true;
}

}

return false;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum