变更地址栏参数
?
?
<html>
<head>
</head>
<body>
<script>
var url='pagename?para=xx¶3=fasfaf¶4=dfa';
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;
}
alert(changeURLPar(url,'para','99'))
</script>
</body>
</html>