Get URL Parameters With JavaScript
Get URL Parameters With JavaScript
The JavaScript function below parses and returns the parameters.
function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; }
Then is how you can pick a value from the url parameter.
var number = getUrlVars()["x"]; var mytext = getUrlVars()["text"]; The Complete jf file would like as:
function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; }
var number = getUrlVars()["x"]; var mytext = getUrlVars()["text"];