JavaScript  -  Screen Width

Option 1.   Save this script in the <head> of your html document

<script type="text/javascript">
var scrW1 = screen.width;
</script>

and use this script in the <body>

<script type="text/javascript">
<!--
document.write(""+scrW1+"px");
//-->
</script>

Screen Width - Displays:

 

Option 2.   Save this script in your js folder

Save the following script as screenwidth.js

<!--
var scrW2 = screen.width;
document.write(""+scrW2+"px");
// or
// document.write(""+screen.width+"px");
// without variable
//-->

and refer to it in the <body> of your html document

<script src="/js/screenwidth.js" type="text/javascript"></script>

Screen Width - Displays:

 

Option 3.   Embed this script in the <body> of your html document

<script type="text/javascript">
<!--
var scrW3 = screen.width;
document.write("Screen Width is "+scrW3+"px");
// or
// document.write("Screen Width is "+screen.width+"px");
// without variable
//-->
</script>

Screen Width - Displays: