Revision: 2499
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 8, 2007 02:55 by 1man
Initial Code
variable = getQueryVariable("what you want to extract");//e.g "source" function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } }
Initial URL
Initial Description
This function extracts a value from a url. Very useful for tracking codes. For example, you have a url http://your.url/?source=666999, and you need the source number to be placed into a variable. Use the code below.
Initial Title
Query Variable Function
Initial Tags
url, query
Initial Language
JavaScript