Screen Resolution Detector

This is a cool trick which is best used to make sure that the layout of your screen is kept consistant and clean - by making sure your visiter has the right resolution. An ecample of this is if your page has a title image 600 pixels wide, and the viewers screen resolution is 640 by 40, there will be a horizontal scroll bar on the page (a big no-no). Using this script will allow you to alert the visiter of their resolution, and if it is wrong, alert them to change it. Here is an example script of a resolution detector for less then 1280 by 1024.

Here is the script:

<script language="Javascript1.1“>
<!--
//this code was designed by Brian Zimmer
function detect(){
if(screen.width<1280||screen.height<1024){
alert(“This webpage is best viewed with a screen resolution of 1280 by 1024 or higher.  Your current resolution is 
“+screen.width+” by “+screen.height+”.  If possible please change your resolution.”)
}
else{
alert("Your resolution is .  Nice Job!")
}

}
//--> 
</script>	

Thats all there is too it. Add this script to your <head> tag. You can change everything in red, to customize it for your page. To load this at start up, add 'onLoad="detect()"' to your <body> tag. If you want to add it to a link or button, add 'onCLick="detect()"'. Good Luck!



Home | Tutorials | Files | Forum | Links | Contact Me | Portfolio