The location, anchor, and history Objects

Using links in HTML is second nature to web developers, and creating links with JavaScript is both easy and much more powerful than what can be done with the <a href="myURL"> tag in HTML. The main linking objects in JavaScript are location and history. When the location object is assigned a URL, you get the same results as linking a page. It has the following format:

						window.location="http//:www.yourURL.something"; 

(This states that the window object is optional, and it typically is not used with location. It is included simply to remind the reader that location is a property of window.)

The location object has eight properties and two methods, as shown in Table 10.1.

Table 10.1. Properties of the location ...

Get JavaScript Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.