How do I retrieve tokens from the current URL using JavaScript

advertisements

Given an URL such as /abc.html#variable1, I want to capture the variable1 part to determine a given user's "virtual page" when working with JavaScript (jQuery).


If I understand your question, you don't need at all jquery, just use

to get the url use

var the_link = document.location

to get just the hash part of the url (the text after #) use

var the_hash = document.location.hash

to get the GET variables you can use

var get_vars = document.location.search