Home > Web Front-end > JS Tutorial > How to get the Get parameters in Url

How to get the Get parameters in Url

php中世界最好的语言
Release: 2018-04-26 17:36:10
Original
2692 people have browsed it

This time I will show you how to get the Get parameters in Url, and what are the precautions for getting the Get parameters in Url. The following is a practical case, let's take a look.

At this time, you can use js to get the get parameters in the URL of the current page. The core statement is:


window.location.href
Copy after login

The detailed code will not be explained, there are

Comments, you will understand after reading it. It is packaged into a jQuery expansion package.

(function($){ 
$.extend({ 
/** 
* url get parameters 
* @public 
* @
return
 array() 
*/ 
urlGet:function() 
{ 
var aQuery = window.location.href.split("?");//取得Get参数 
var aGET = new Array(); 
if(aQuery.length > 1) 
{ 
var aBuf = aQuery[1].split("&"); 
for(var i=0, iLoop = aBuf.length; i<iLoop; i++) 
{ 
var aTmp = aBuf[i].split("=");//分离key与Value 
aGET[aTmp[0]] = aTmp[1]; 
} 
} 
return aGET; 
}, 
}); 
})(jQuery);
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

jquery js gets focus control image

jquery operation animation display and hiding effect

Detailed explanation of jquery switching tabs method

The above is the detailed content of How to get the Get parameters in Url. For more information, please follow other related articles on the PHP Chinese website!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template