Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Detect-and-route with JavaScript

Keep users happy by using savvy scripts

Return to article.


Listing 7. This script tests for screen resolution and presents the correct pages for the browser's screen

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function redirectPage() {
var url640x480 = "http://www.yoursite.com/640x480";
var url800x600 = "http://www.yoursite.com/800x600";
var url1024x768 = "http://www.yoursite.com/1024x768";
if ((screen.width == 640)  (screen.height == 480)) 
window.location.href= url640x480;
else if ((screen.width == 800)  (screen.height == 600))
window.location.href= url800x600;
else if ((screen.width == 1024)  (screen.height == 768))
window.location.href= url1024x768;
else window.location.href= url640x480;
}
// End -->
</SCRIPT>


Return to article.