Get URL Variables/parameters values With JavaScript


javscript function ///
//name = Pass URl parameter
function getParameterByName(name) {
alert(name);
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
var result= match && decodeURIComponent(match[1].replace(/\+/g, ' '));
alert(result);
}

// ]]>


and buttun onclick event onclick=”javascript:getParameterByName(‘utm_source’);”
URL = javascript_get_parameter.html?utm_source=massmail&utm_medium=email&utm_campaign=21-feb-2015

Advertisements