I want to get current page URL using javascript ,Any one have suggestions ?
Also i need to get the content from the hashtag For ex: xxxx.com/#21 i need to get that 21 in the javascript
I want to get current page URL using javascript ,Any one have suggestions ?
Also i need to get the content from the hashtag For ex: xxxx.com/#21 i need to get that 21 in the javascript
Use next:
HREF = document.location.href
HASH = document.location.hash
http://www.w3schools.com/jsref/prop_loc_href.asp
http://www.w3schools.com/jsref/prop_loc_hash.asp
To get the entire current URL, use:
var currentURL = window.location;
Then to get the hash, without the # itself, use:
var trimmedHash = window.location.hash.substr(1);
// returns `21` from `xxxx.com/#21`
window.location.hash returns #21, and substr(1) returns all but the first character of that string, thus removing the #.
try:
window.location.hash // will result #21
window.location.hash.substr(1) // will result 21
hope that helps.