Surfer Redirection Using JavaScript

Stephen Yagielowicz

Using JavaScript to redirect visitors to your site to pages that are optimized for them has many benefits, and enables you to provide the most enhanced surfing experience possible. Here are a few of the scripts that I employ to make this process possible:

JavaScript Redirect
This code allows you to automatically redirect JavaScript enabled browsers to one page, while displaying a text link and / or message to non-JavaScript enabled browsers. This is especially useful if you (as I do) like to employ "gee-whiz" JS-based nav systems, or even a mundane "drop-down" box navigation, since you can easily filter non-JS users to your pages that use text-link or graphical button "only" based nav system:

<!-- JavaScript Redirect
// JavaScript Redirect -->
Your browser either does not support JavaScript, or you have it disabled. Click <A href="">Here</A> to Continue.

Browser Redirect
If you build different pages for MS Internet Explorer and Netscape Navigator, you can use this script to send visitors to the correct browser-optimized page. While I do not personally build entire sites tailored for a specific browser, I will tailor the navigational components of a frames-based site to enable the "happiness" that the use of MSIE allows, for example, sending surfers to either "frameset-ie.shtml" or "frameset-ns.shtml" as the case may be:

<!-- Browser Redirect
if (navigator.appName.indexOf("Explorer") != -1){
window.location = "";}
if (navigator.appName.indexOf("Netscape") != -1){
window.location = "";}
// Browser Redirect -->

Screen Resolution Redirect
This lets you redirect your visitors with 640x480 displays to one page, 800x600 to another, etc. Just as I do not (really) build different sites for different browsers, I do not (really) build different sites for different screen resoultions – but I may build sites that will be encapsulated into a new frameset if the user has a high screen resolution. This lets me use better navigation, and provides increased advertising opportunities. Here's the script:

<!-- Screen Resolution Redirect
if ((navigator.appVersion.indexOf("4.") != -1) && (navigator.appName.indexOf("Netscape") != -1) || (navigator.appVersion.indexOf("4.") != -1) && (navigator.appName.indexOf("Explorer") != -1)){ size = screen.width + "x" + screen.height; if (size == "640x480"){ top.location = ""; } }
// Screen Resolution Redirect -->

As you can see, there are many benefits to redirecting surfers to pages tailored specifically for them, and using a few simple JavaScripts – rather than making them select options through a series of text links, is the way to go. Try a few of these out on your site, and stay tuned for more!