Php javascript重定向赢得';不行?

Php javascript重定向赢得';不行?,php,javascript,redirect,Php,Javascript,Redirect,我有一点javascript代码,可以从php获取一些参数。php变量$rid是一个值在1-100之间的整数。我试图做的是将querystring中“rid”变量的值更改指定的量(偏移量)。当我从window.location.href中删除最后一个str($rid)字符时,剩下的是http://www.qwerty.asdf/uiop?rid=。当我向它添加+偏移量时,我得到http://www.qwerty.asdf/uiop?rid=2例如。当我尝试代码时,什么也没发生,但我已经调试过了,

我有一点javascript代码,可以从php获取一些参数。php变量$rid是一个值在1-100之间的整数。我试图做的是将querystring中“rid”变量的值更改指定的量(偏移量)。当我从
window.location.href
中删除最后一个
str($rid)
字符时,剩下的是
http://www.qwerty.asdf/uiop?rid=
。当我向它添加
+偏移量时,我得到
http://www.qwerty.asdf/uiop?rid=2
例如。当我尝试代码时,什么也没发生,但我已经调试过了,当我说
window.location.href=str时str是所需的值

为什么页面不重定向?我尝试了window.location而不是window.location.href,但不起作用

p、 页面上没有其他javascript

function moveRid(offset) {
    str = window.location.href.substring(0,window.location.href.length-<?php echo strlen($rid);?>);
    rid = <?php echo $rid;?>+offset;
    str += rid;
    window.location.href=str;
}
函数moveRid(偏移量){
str=window.location.href.substring(0,window.location.href.length-);
rid=+偏移量;
str+=rid;
window.location.href=str;
}

您需要实际设置window.location

function moveRid(offset) {
    str = window.location.href.substring(0,window.location.href.length-<?php echo strlen($rid);?>);
    rid = <?php echo $rid;?>+offset;
    str += rid;
    //window.location.href=str;
    window.location = str;
}
函数moveRid(偏移量){
str=window.location.href.substring(0,window.location.href.length-);
rid=+偏移量;
str+=rid;
//window.location.href=str;
window.location=str;
}

我尝试过这个,但它不起作用。。。我认为window.location.href是执行此操作的“正确方式”,所以我就是这么做的。当您在我的window.location=str;上方执行警报(str)时,您会看到什么?这就是我所说的调试,我得到:
http://www.mysite.com/file.php?rid=2
但我还是呆在
http://www.mysite.com/file.php?rid=1
如果页面上没有其他JS,何时以及如何调用该函数?加载/点击?