You need not necessarily visit the server side scripts (such as VBscript) to retrieve the variables passed across from the prior page. The same result can be produced using just Javascripts.
Variables passed from the last page can be retrieved in your current page in a Javascript function as follows:
|
function fn_RetrieveVariables() { // Identify browser type var strNav, strIE, strBrowser; strNav = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 3);
strIE = (navigator.appName.indexOf("Microsoft") >= 0 && parseInt(navigator.appVersion) >= 4) ;
strBrowser = strNav || strIE;
var results = new Array();
if (strBrowser) { // strip away leading question mark var input = unescape(location.search.substring(1)); if (input) { // Divide long string into array of name/value pairs. var srchArray = input.split("&"); var tempArray = new Array(); for (i = 0; i < srchArray.length; i++) { /* Divide each name-value pair into a two-entry array.*/ tempArray = srchArray[i].split("="); results[tempArray[0]] = tempArray[1]; } } } return results; } |
Variables Value1 and Value2 passed from prior page as:
mytestpage.html?Value1=1&Value2=2
can be retrieved in results of the above function.
For users averse to passing query strings, the same works effectively with hidden variables too.