From Bob Brandt's Projects Site

Other: JavaScript HTTP Redirect page

Very often I need to install a service on a server where the following is true:

If all these conditions are true, I place a simple HTTP JavaScript Redirect as the default index.html page which, as the name implies, redirects the browser to the correct page.

I am sure that there are ways to do the same with Python, PHP or Perl; but I use this script as it is easy, and low tech.

<html>
   <!-- This is all just a super-duper redirect to the Welcome page
        If the user has Javascript 1.1 installed, they don't get their history
        messed up.  Otherwise, it behaves like a normal redirect, and even has
        fallbacks to non JS and browsers that don't handle the meta refresh tag
     -->
   <head>
      <script language="JavaScript">
         <!--
         var sThisURL = window.location.href;
         sThisURL = sThisURL.substring(0, location.href.lastIndexOf('\/'));
         sThisURL = unescape( sThisURL + ':8080/IDMProv');

         function doRedirect()
         {
            actualRedirect();
         }

         function actualRedirect()
         {
            setTimeout( "top.location.href = sThisURL", 500 );
         }
         //-->
      </script>
      <script language="JavaScript1.1">
         <!--
         function actualRedirect()
         {
            // this is a better way to do it if we have JS 1.1, not adding 
            // to the browser's history
            top.location.replace( sThisURL );
         }
         if ( "MSIE" == navigator.appName )
         doRedirect();
         //-->
      </script>
   </head>
   <body bgcolor="white" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" onLoad="doRedirect()"></body>
</html>
Retrieved from /projects/pmwiki.php?n=Other.HTTPRedirect
Page last modified on February 18, 2008, at 11:54 AM