Re-Direct On Users Screen Size

[Total: 0    Average: 0/5]

This shows how to use the screen size of the user to send that user to an appropriate page.

Head Code:

<script type=text/javascript>
function doIt() {
  if (navigator.appVersion.indexOf("4.") != -1 &&
     (navigator.appName.indexOf("Netscape") != -1 ||
      navigator.appName.indexOf("Explorer") != -1)){
    size = screen.width + "x" + screen.height;
    if (size == "640x480")  { document.location = "http://www.js-examples.com/"; }
    if (size == "800x600")  { document.location = "http://www.js-examples.com/js/"; }
    if (size == "1024x768") { document.location = "http://www.js-examples.com/js/index.html"; }
  }
}
// un-comment this code (next line) to have it run automatically
// doIt();
</script>

Body Code:

<BR><a href="javascript:doIt()">Click Here</a>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *