Home > php教程 > php手册 > JS仿PHP$_GET获取get参数

JS仿PHP$_GET获取get参数

WBOY
Release: 2016-06-06 20:10:22
Original
900 people have browsed it

var $_GET = (function(){var url = window.document.location.href.toString();var u = url.split("?");if(typeof(u[1]) == "string"){u = u[1].split("var get = {};for(var i in u){var j = u[i].split("=");get[j[0]] = j[1];}return get;} else {return

var $_GET = (function(){
	var url = window.document.location.href.toString();
	var u = url.split("?");
	if(typeof(u[1]) == "string"){
		u = u[1].split("&");
		var get = {};
		for(var i in u){
			var j = u[i].split("=");
			get[j[0]] = j[1];
		}
		return get;
	} else {
		return {};
	}
})();
Copy after login

/*使用时, 可以直接 $_GET['get参数'], 就直接获得GET参数的值*/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template