JS Modify Address Bar Parameter Instance Code
- 2021-06-28 10:44:18
- OfStack
No more nonsense, work directly for everyone, my style, you know.
The key 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_r(tmp), replaceText);
return (tmp);
}
else
{
if (destiny.match('[\?]'))
{
return destiny+'&'+ replaceText;
}
else
{
return destiny+'?1=1&'+replaceText;
}
}
return destiny+'\n'+par+'\n'+par_value;
}
Changing the Address Bar Content dynamically with JS window.location.href window.location.hash
With window.location.hash, you can change the address bar content without committing as you would with wndow.location.href.
When hash is changed, the address bar will be followed by #,,, and so on.This can solve the location of the page in the AJAX refresh-free state, and can also complete some interface effects in the refresh-free state to make good use of the future.Good East.