Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

The Location Object

When you load a Web page into your browser, the path or URL to that page is stored in the window.location object. You can retrieve the page's URL from the location object, or you can load a different page into the window by using the location object's assign or replace methods.

Location Object Properties

href The URL of the current page
protocolThe URL's protocol, usually http:
host The hostname and port number
hostnameThe name of the host
pathnameThe path relative to the current directory
port The port number (default http port is 80)
hash An inpage anchor (#) attached to URL
search A query string (?) attached to URL

Location Object Methods

reload() Reloads the current page
replace("URL") Loads the specified URL and disables the Back button
assign("URL") Loads the specified URL, does not disable the Back button

The example code below shows the location object's replace method being executed by the document's onload event. This causes the webpage to be replaced by the page at the specified URL immediately after it completes loading.

<body onload="window.location.replace('page2.htm')">

Note the same action can be performed without Java Script using a refresh meta tag with its content attribute set to 0, as shown below.

<meta http-equiv="refresh" content="0;url=page2.htm">

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Web Design Sections

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2016 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268