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

Navigating to a New URL

The location object is probably best known for enabling you to navigate to a new URL, and we’ve seen that as long ago as Chapter 4. Here’s that example; in this case, we let the user enter a URL and make the browser navigate to that URL when she clicks a button (Listing 04-06.html on the web site):

<HTML> 
    <HEAD> 
        <TITLE> 
            Navigate to an URL 
        </TITLE> 
        <SCRIPT LANGUAGE = "JavaScript"> 
            <!--
            function Jump() 
            { 
                window.location.href = document.form1.text1.value 
            } 
            // --> 
        </SCRIPT> 
    </HEAD> 

    <BODY> 
        <H1>Navigate to an URL</H1> 
        <FORM NAME = "form1">
					<BR>
					<INPUT TYPE = TEXT NAME="text1" SIZE = 80>
					<BR>
					<BR>
					<INPUT TYPE = BUTTON Value="Navigate to URL" ONCLICK="Jump()">
					</FORM> 
    </BODY> 
</HTML> 

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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