how to get current screen resolution in javascript?

ctlo
ctlo used Ask the Experts™
on
how to get current screen resolution in javascript?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try this ...

<html>
<head>
</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from old browsers that do not support JavaScript.

  var ScrnSize = "UnCommon"

  if (navigator.appVersion.indexOf("4.") != -1 && 
      navigator.appName.indexOf("Explorer") != -1) {
     ScrnSize = screen.width + "x" + screen.height;
  }
  if (navigator.appVersion.indexOf("4.") != -1 && 
      navigator.appName.indexOf("Netscape") != -1) {
     ScrnSize = screen.width + "x" + (screen.height + 19); //Netscape sees 19 pixels less on Height
  }
 
  document.write('Browser Type=' + navigator.appName + '<BR>');
  document.write('Browser Version=' + navigator.appVersion + '<BR>');
  document.write('Screen Resolution=' + screen.width + "x" + screen.height);

// End hiding -->
</SCRIPT>


</body>
</html>
IT Expert
Top Expert 2009
Commented:
what a strange test.

Anand:
   if(window.screen) {    
      ScrnSize = screen.width + "x" + (appName=="Netscape")?screen.height+19:screen.height;
 }

Michel
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Sorry - duplicate post - please delete
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

What does that 19 do?
Michel PlungjanIT Expert
Top Expert 2009

Commented:
There is an offset difference between IE and netscape...

Michel PlungjanIT Expert
Top Expert 2009

Commented:
ctlo,
No comment has been added lately (0 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to mplungjan http:#7462767

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

mplungjan
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial