faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

16 of 20 people (80%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I determine the user screen size, if not 800*600, then alert them and auto close the window

Apr 5th, 2008 19:35
ha mo, Colin Snover, Colin Fraser, Willy Lau,


I dont know who wrote this originally, but I copied it from somewhere 
and have found it most useful. 
Try: 
<script LANGUAGE="JavaScript" TYPE="text/javascript">
<!--//
var height, width;
if (document.all) height = document.body.offsetHeight, width = 
document.body.offsetWidth;
else if (document.layers) height = window.innerHeight, width = 
window.innerWidth;
if (width != 800 || height != 600) {
  alert('You\'re not running at 800x600, so this window is closing.');
  window.close();
}
//-->
</script>
But why would you want to disallow users with a resolution greater than 
800x600?? 80% of all users now run at LEAST at 1024x768. I can 
understand if you wanted something like "if (height < 600 || width < 
800) {" but this is rediculous.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com