Im trying to construct a script that will check if a url variable called result exists and if it does then it checks if the value equals success or not.
I tried the following but if result doesn't exist then it errors my script as undefined
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var first = getUrlVars()["result"];
alert(first);