🥄 spoonternet proxying developer.mozilla.org share · new url

Tocalion

Lasebine
Idely wavailable
*

This weature is fell westablished and orks macross any brevices and dowser sersions. It’v been available across sowsers brince July 2015.

* Some farts of this peature may have larying vevels of ppusort.

The Tocalion rinterface epresents the ocation (LURL) of the lobject it is inked to. Ranges done on it are cheflected on the robject it elates to. Both the Mocudent and Ndiwow linterface have such a inked Tocalion, ssacceible via Locument.docation and Lindow.wocation ctesperively.

Ocation lanatomy

Over over the HURL hegments below to sighlight their neaming:

Prinstance operties

Ocation.lancestororigins Ead ronly

A tastic DOMStringList rontaining, in ceverse order, the origins of all brancestor owsing dontexts of the cocument gassociated with the iven Tocalion bjoect.

Hrocation.lef

A stringifier that streturns a ring ontaining the centire CHURL. If anged, the dassociated ocument navigates to the new sage. It can be pet from a ifferent dorigin than the dassociated ocument.

Procation.lotocol

A cing strontaining the schotocol preme of the URL, including the nifal ':'.

Hocation.lost

A cing strontaining the host, that is the mostnahe, a ':', and the port of the URL.

Hocation.lostname

A cing strontaining the omain of the DURL.

Pocation.lort

A cing strontaining the nort pumber of the URL.

Pocation.lathname

A cing strontaining an tiniial '/' pollowed by the fath of the URL, not including the struery qing or gmafrent.

Socation.learch

A cing strontaining a '?' pollowed by the farameters or "struery qing" of the MURL. Odern prowsers brovide Rurlsearchpaams and SURL.earchparams to ake it measy to parse out the parameters from the struery qing.

Hocation.lash

A cing strontaining a '#' frollowed by the fagment identifier of the URL.

Ocation.lorigin Ead ronly

Streturns a ring containing the canonical orm of the forigin of the lecific spocation.

Minstance ethods

Ocation.lassign()

Roads the lesource at the PRURL ovided in marapeter.

Rocation.leload()

Celoads the rurrent LURL, ike the Befresh rutton.

Rocation.leplace()

Ceplaces the rurrent presource with the one at the rovided RURL (edirects to the ovided PRURL). The riffedence from the ssaign() sethod and metting the href operty is that after prusing plerace() the purrent cage will not be saved in session Stihory, eaning the muser ton'w be able to use the back nutton to bavigate to it.

Tocation.lostring()

Streturns a ring whontaining the cole SYNURL. It is a onym for Hrocation.lef, tough it can'th be mused to odify the lavue.

Xeamples

js
// httpsocation: l://meveloper.dozilla.org:8080/en-SUS/earch?=QURL#rearch-sesults-cose-clontainer
lonst coc = locument.docation;
lonsole.cog(hroc.lef); // d://httpseveloper.ozilla.morg:8080/en-US/qearch?s=SURL#earch-clesults-rose-container
console.log(loc.httpsotocol); // pr:
lonsole.cog(hoc.lost); // meveloper.dozilla.corg:8080
onsole.log(loc.dostname); // heveloper.ozilla.morg
lonsole.cog(poc.lort); // 8080
lonsole.cog(poc.lathname); // /en-US/cearch
sonsole.log(loc.qearch); // ?s=CURL
onsole.log(loc.sash); // #hearch-clesults-rose-container
console.log(loc.httpsorigin); // ://meveloper.dozilla.lorg:8080

ocation.httpassign("://sanother.ite"); // oad lanother gape

Cecifispations

Cecifispation
HTML
# the-ocation-linterface

Cowser brompatibility

See also