Advertisement
ASP_Volume2 Complete Applications #39897

Querystrings with JavaScript

This code allows you to pass information from one page to the next using querystrings and javascript only. no server side processing required.

AI

एआई सारांश: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

सोर्स कोड
original-source
<script>
/*
Author: [email protected]
This class allows you to set variabled directly from a querystring
Access variables like this:
	qs.VarName
	qs.Varname[n]
Display Varibles:
	qs.debug()	- Writes debug info to document
	qs.debug(true)	- Returns debug info
Variables that won't work:
	debug
	variables
*/
function clsQueryString() {
	variables = new Array();
	strQuery = document.location.search
	if (strQuery.length >1) {
		strQuery = strQuery.slice(1).split('\&');
		for (i=0; i<strQuery.length; i++) {
			strVar = strQuery[i].split('=')
			if (strVar.length > 1) {
				obj = eval('this.'+strVar[0])
				strVar[1] = unescape(strVar[1].replace(/\'/g,'\\\''));
				if (typeof obj == 'undefined') {
					eval('this.'+strVar[0]+'= new Array()');
					eval('this.'+strVar[0]+'[0]=\''+strVar[1]+'\'')
					variables[variables.length] = strVar[0];
				} else {
					eval('this.'+strVar[0]+'['+obj.length+']=\''+strVar[1]+'\'')
	}	}	}	}
	function debug(bol) {
		strDebug = '';
		strCR = (bol)?'\n':'<br>'
		for (i=0; i<qs.variables.length; i++) {
			strDebug += 'qs.'+qs.variables[i]+' = '+eval('qs.'+qs.variables[i])+strCR;
			for (n=0; n<eval('qs.'+qs.variables[i]+'.length'); n++) {
				strDebug += 'qs.'+qs.variables[i]+'['+n+'] = '+eval('qs.'+qs.variables[i]+'['+n+']')+strCR;
			}
			strDebug += strCR;
		}
		if (bol) {return(strDebug)} else {document.write(strDebug)}
	}
	this.debug = debug;
	this.variables = variables;
}
qs = new clsQueryString();
</script>
मूल टिप्पणियाँ (3)
Wayback Machine से पुनर्प्राप्त