In previous tutorial, we talk about Window Object little bit now let’s get dive into Location object.
The Location Object:
Sometimes an object in the hierarchy represents something that doesn’t seem to have the kind of physical presence that a window or a button does.
That’s the case with the location object. This object represents the URL loaded into the window.
This differs from the document object because the document is the real content; the location is simply the URL.
Unless you are truly Web-surfer, you may not realize a URL consists of many components that define the address and method of data transfer for a file.
Pieces of a URL include the protocol (such as http:) and the hostname (such as www.visionsdeveloper.com). You can access all of these items as properties of the location object.
For the most part, though, your scripts will be interested in only one property: the href property, which defines the complete URL.
Setting the location.href property is the primary way your scripts navigate to other pages:
location.href = “http://www.visionsdeveloper.com”;
You can generally navigate to a page in your own Web site by specifying a relative URL rather than the complete URL with protocol and host information.
For pages outside of the domain of the current page, you need to specify the complete URL.
If the page to be loaded is in another window or frame, the window reference must be part of the statement.
For example, if your script opens a new window and assigns its reference to a variable named newWindow, the statement that loads a page into the subwindow is