Detect the screen resolution with JavaScript - Web Development and Web Design Codes

Latest

Thursday, April 19, 2018

Detect the screen resolution with JavaScript

Detect the screen resolution with JavaScript


Hi guys in this lesson we are going to learn how to detect user monitor height and weight info with JavaScript..
please copy and run the below JavaScript codes to detect user screen resolution..

detect.html


<script>
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
 screenW = screen.width;
 screenH = screen.height;
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenW = jScreenSize.width;
 screenH = jScreenSize.height;
}

document.write(
 "screen width = "+screenW+"<br>"
+"screen height = "+screenH
)
</script>

That's it friends how to get screen width and height in JavaScript ..thank fo visiting...please share with your friends..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.