Changes

Jump to: navigation, search

JavaScript Location Object

3 bytes added, 15:21, 15 April 2009
no edit summary
== Loading a New URL into the Current Window ==
The location object contains a number of methods and properties that enable the JavaScript developer to manipluate manipulate the current URL of a window. A commom common example is to progammatically programmatically change the current window URL. This can be done by assigning a new URL string to the ''href'' property of the Location option:
<pre>
<nowiki>http://www.techotopia.com:80/order.cgi?batch=1#intro</nowiki>
the The following properties represent the various elements of the URL:
* '''location.protocol''' - the protocol section of the URL (for example http: or https:)
The JavaScript Location Object contains two methods that may be invoked from JavaScript. These are:
* '''location.reload()''' - reloads the current document. The same as pressing the ''Reload'' button in the browser window. If ''true'' is passed through as an argument (i.e . ''location.reload(true)'') it forces a reload without using the browser cache (similar to shift clicking on the browser ''Reload'' button.
* '''location.replace()''' - replaces the current URL with the new URL specified as an argument (i.e . ''location.replace(<nowiki>"http://www.techotopia.com"</nowiki>)''. Change does not get recorded to the browser's history (see [[JavaScript History Object]]).

Navigation menu