location.pathname
pathname
se única devolver la ruta. Si desea querystring
y opcionalmente hash
, deberá combinar las propiedades search
y hash
también. Considere esta url:
http://www.example.com/path/to/glory?key=value&world=cup#part/of/page
location.pathname => "/path/to/glory"
location.search => "?key=value&world=cup"
location.hash => "#part/of/page"
Si desea toda la cosa,
/path/to/glory?key=value&world=cup#part/of/page
a continuación, sólo concatenar todas estas cosas:
location.pathname + location.search + location.hash
siempre quiso utilizar with
en alguna parte. Esto se ve como la oportunidad perfecta :)
with(location) {
pathname + search + hash;
}
¿Qué podría tener esto que ver con jQuery? –
Anurag: mientras edita, puede deshacerse de la llamada redundante 'toString' en' location.host'. –
yikes @no, ¿lo sobreescribí mientras cambiabas? – Anurag