Currently, webpage processing often encounters the problem of Address Bar parameters. Therefore, we have made a special method to modify the address bar parameters. For more information, see the current webpage, we often encounter problems in processing address bar parameters, but we always do it by feeling, and we don't know where to change the parameters. Therefore, we have made a special method to modify the address bar parameters, you don't have to worry about it anymore. Haha!
The following is my compilation method, which is easy to use.:
The Code is as follows:
Function changeURLPar (destiny, par, par_value)
{
Var pattern = par + '= ([^ &] *)';
Var replaceText = par + '=' + par_value;
If (destiny. match (pattern ))
{
Var tmp = '/\' + par + '= [^ &] */';
Tmp = destiny. replace (eval (tmp), replaceText );
Return (tmp );
}
Else
{
If (destiny. match ('[\?] '))
{
Return destiny + '&' + replaceText;
}
Else
{
Return destiny + '? '+ ReplaceText;
}
}
Return destiny + '\ n' + par +' \ n' + par_value;
}
Destiny is the target string, for example, http://www.huistd.com /? Id = 3 & ttt = 3
Par is the parameter name and par_value is the value to be changed. The call result is as follows:
ChangeURLPar (test, 'id', 99); // http://www.huistd.com /? Id = 99 & ttt = 3
ChangeURLPar (test, 'hahaha', 33); // http://www.huistd.com /? Id = 99 & ttt = 3 & haha = 33
How are you doing? It's quite helpful! Haha