Get the full url including hash with content in JavaScript

Viewed 20955

How can I get url with content after hash ?

window.location return me url without hash :/

for example:

www.mystore.com#prodid=1

window.location return only www.mystore.com

5 Answers

You have to build it up yourself:

// www.mystore.com#prodid=1
var sansProtocol = window.location.hostname 
    + window.location.hash;

// http://www.mystore.com#prodid=1
var full = window.location.protocol 
    + "//" 
    + window.location.hostname 
    + window.location.hash;
Related