Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Intermediate
Apr 23, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Send Visitors to the Front Page

Many Web site managers prefer all site visitors to enter their site through the front page. The front page may contain site usage information that all users should see, or navigation tools that they'll be lost without. In any case, you can ensure that all visitors go to the front page first by checking the referring page with JavaScript and redirecting if necessary. If the referring URL doesn't contain your site's domain name, chances are it came from an outside link. This JavaScript function checks the referring URL for the domain name "razorfish", and if it doesn't find it sends the user to the front page of the Razorfish site.
     function redirect() {
          if (document.referrer.indexOf("razorfish") == -1) {
                  window.location = "http://www.razorfish.com";

<BODY onload="redirect()";>


Steve Renaker
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date