Locationinterface represents the location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the
Windowinterface have such a linked
Location, accessible via
.assign()method causes the window to load and display the document at the URL specified.
Location.reload()method reloads the resource from the current URL. Its optional unique parameter is a
Boolean, which, when it is
true, causes the page to always be reloaded from the server. If it is
falseor not specified, the browser may reload the page from its cache. Besides caching behaviour
forcedReloadflag also impacts how some browsers handle scroll position: ordinary reload happens to try to restore scroll position after reloading page DOM, while in forced mode (when parameter is set to
true) the new DOM gets loaded with
scrollTop == 0.
.replace()method replaces the current resource with the one at the provided URL. The difference from the
assign()method is that after using
replace()the current page will not be saved in session
History, meaning the user won't be able to use the back button to navigate to it.
HTMLHyperlinkElementUtils.hrefproperty is a
USVStringcontaining the whole URL.
HTMLHyperlinkElementUtils.toString()stringifier method returns a
USVStringcontaining the whole URL. It is a read-only version of
locationread-only property of the
WorkerGlobalScopeinterface returns the
WorkerLocationassociated with the worker. It is a specific location object, mostly a subset of the
Locationfor browsing scopes, but adapted to workers.