location.href是地址,而不是变量?地址是会自动加上前面那些的

解决方案 »

  1.   

    因为js是解释型语言,
    在window.location.href="GroupPhsManage.jsp";这句还没跳转的时候。已经执行了
    alert(window.location.href);
      

  2.   

    location.href指向要转到的地址而不是一个变量
      

  3.   

    既然都执行到alert了,说明此时页面还没有跳转,当然显示原来的页面地址。
    如果立即跳转,那么就不执行alert了
      

  4.   

    试试这个就清楚了
    <script>
    function go(){
    window.location.replace("GroupPhsManage.jsp");
    setTimemout("alert(window.location.href)",1000);
    }
    </script>
    <input type="button" onclick="go()" value="haha" />
      

  5.   

    var window=new Object();
    window.location=new Object();
    window.location.href="GroupPhsManage.jsp";
    alert(window.location.href);这样就出来GroupPhsManage.jsp了,哈哈
      

  6.   

    你要干嘛?如果要显示跳转的页面就在那个页面写ALERT啦
    你在这个页面写的话 当然是显示这个页面的地址啦~~
      

  7.   

    大家似乎没有明白我的意思我是说,我觉得应该是这样的:
    要么就转到GroupPhsManage.jsp并且alert出GroupPhsManage.jsp,或者不alert;
    要么就不跳转,alert出当前页面的路径。但现在的情况是:先执行alert出当前页面的路径,再跳转。
    是不是href会自动在function的最后时刻执行而先执行后面的语句?
      

  8.   

    window.location.href 只是一个字符串而已,并不会执行跳转事件
    你要跳转的话就 window.location="" 
    在执行了window.location后alert()是不会执行的