The Screen Object
By Stephen Bucaro
Maybe your layout is such that the user must have a certain screen size, a
minimum screen size, or a certain color depth for your webpage to look right.
The Screen object gives you that information about the user's sreen.
Object Property | Returns |
screen.width | The screen width in pixels |
screen.height | The screen height in pixels |
screen.availWidth | Available screen width after subtracting for task bar |
screen.availHeight | Available screen height after subtracting for task bar |
screen.colorDepth | Number of bits used to store a color pixel |
screen.fontSmoothingEnabled | Font Smoothing as set in Windows Control Panel |
Click Here to get screen information.
<script type="text/javascript">
function screenInfo()
{
var outStr = "Screen Width= " + screen.width + "<br />";
outStr += "Screen Height= " + screen.height + "<br />";
outStr += "Available Screen Width= " + screen.availWidth + "<br />";
outStr += "Available Screen Height= " + screen.availHeight + "<br />";
outStr += "Color Depth= " + screen.colorDepth + "<br />";
outStr += "Font Smoothing Enabled= " + screen.fontSmoothingEnabled + "<br />"
document.getElementById("scrninfo").innerHTML = outStr;
}
</script>
Note: The screen object is a property of the window object, but you don't need to
specify the window object when calling the screen object because the window object
is the default object.
window.resizeTo(screen.availWidth, screen.availHeight);
An example use of the Screen object might be to use the window object's resizeTo method
to make the users browser window go full-screen when it displays your webpage.
More Java Script Code: • Extract Part of a String • Determine Absolute Value • The Browsers History Object • Using the Java Script eval() Function • Java Script Math.cos Method • Remove Blank Spaces From Ends of a String • Interactively Set Webpage Colors • Java Script Math.tan Method • Cookie Power Made Easy • The while Loop
|