Link to home
Start Free TrialLog in
Avatar of ctlo
ctlo

asked on

how to get current screen resolution in javascript?

how to get current screen resolution in javascript?
Avatar of anandnerkar
anandnerkar

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>
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry - duplicate post - please delete
What does that 19 do?
There is an offset difference between IE and netscape...

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