Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Desktop size in javascript
#1
Is it possible to detect the viewer's desktop size using javascript? I have to know it in order to resize a javascript popup window according to the desktop size.

All I can find is code to detect the window size, just like this snippet:

Code:
<script language=javascript>
if((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >=4)){
windowwidth = window.innerWidth;
windowheight = window.innerHeight;
}
else if((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >=4)){
windowwidth = document.body.clientWidth;
windowheight = document.body.clientHeight;
}else{
windowwidth = 800;
windowheight = 600;
}
document.write("Your browser window has a height of " + windowheight + ".
");
document.write("Your browser window has a width of " + windowwidth + ".
");
</script>
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#2
No problem, I found it Wink

I could've deleted the post, but I think the snippet may be useful for somebody, so I post it here anyways:

Code:
<SCRIPT LANGUAGE="JavaScript">

document.write('<b>Your screen size is '  + screen.width + ' x ' +  screen.height)

</SCRIPT>

I can't believe it was that easy :o
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
Just like in VBScript... it is that easy... Wink
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)