• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Redirecting a Browser

You also can use the location object to redirect a browser as soon as a page loads—for example, to a page with browser-specific code. We saw how to do that in Chapter 4 as well—this is Listing 04-09.html on the web site (note that this code also redirects browsers that don’t support scripting using a <META> element):

<HTML> 
    <HEAD> 
        <TITLE>Redirecting Browsers</TITLE> 
        <SCRIPT LANGUAGE="JavaScript"> 
            <!--
            if (navigator.appName == "Microsoft Internet Explorer") {
					window.location.href = "IE.html"
					}
					if(navigator.appName == "Netscape") {
					window.location.href = "NS.html"
					} 
            //--> 
        </SCRIPT> 
        <META HTTP-EQUIV="refresh" CONTENT="0; URL=default.html"> 
    </HEAD> 

    <BODY> 
        <H1>Redirecting Browsers</H1> 
    </BODY> 
</HTML> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint