Advertisement
4_2005-2006 Complete Applications #160287

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

Yapay Zeka Özeti: 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.

Kaynak Kod
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>
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı