I used the below code to pull a get variable from URL. It works in Chrome and FF but not in IE.
www.example.com/index.php?link=123
In Chrome/FF, the variable first
returns "123"
but in IE the variable first
returns "www.example.com/123"
Any ideas on how to fix the code so that in IE it returns "123"
?
function getUrlVars() {
var map = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value {
map[key] = value;
});
return map;
}
var first = getUrlVars()["link"];