Tag Archives: variables

How to get variables from a URL using Javascript

How to get variables from a URL using javascript. // ex url: http://www.example.com/index.html?hello=bonjour&goodevening=bonsoir var hash = getUrlVars(); alert(hash['hello']); // prints ‘bonjour’ function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf(‘?’) + 1).split(‘&’); for(var i = 0; i … Continue reading

Posted in Javascript | Tagged , , | 2 Comments