This article describes how to obtain link parameters in JavaScript. If you want to use url to transmit parameters, you should be familiar with it. For example:
Http://www.softwhy.com/home.php? Mod = space & do = home & view = all
Since parameters are passed, we naturally need to obtain the passed parameters. Of course, there are many ways to obtain parameters. Here we will introduce one of them and share them with you, the Code is as follows:
var url="http://www.softwhy.com/home.php?mod=space&do=home&view=all";if(url.indexOf("?")!=-1) {var str=url.substr(url.indexOf("?")+1);strs=str.split("&");for(i=0;i
');}}
In the above link:
1. The length of strs. length is 3.
2. strs [0]. split ("=") [0] Is mod, and strs [0]. split ("=") [1] is space.
3. strs [1]. split ("=") [0] is do, and strs [1]. split ("=") [1] is home.
And so on.
We will share with you three examples of code for obtaining the address bar parameters in JS.
Sometimes, we need to get the address bar parameter value of the static page. JS is the easiest way to use. The following three function codes are collected for obtaining the address bar parameters using javaScript, which is easy to use, the following code is shared with you one by one:
JS to obtain the address bar string parameters, Method 1: