http://www.51js.com/viewthread.php?tid=22720&&name=qq&&commandname=add&&age=16参数传递过来
window.location.search后我想截掉“commandname=add”部分,可以怎么做?

解决方案 »

  1.   

    replace也可以啊s = window.location.search.replace(/commandname=add/i,"")
      

  2.   


    直接从url地址栏截掉???你需要重新设置过url如果你只是需要一个变量不包含commandname=add,去掉就好了var s=window.location.search;
    s=s.replace(/commandname=[^&]*/gi,"");
    alert(s)
    //如果需要重设url,取消下面的注释
    //window.location=window.location.pathname+s;
      

  3.   

    嗯,是的,要去掉“commandname=add”,然后再重新指定
      

  4.   

    var s=window.location.search;
    s=s.replace(/commandname=[^&]*/gi,"");
    alert(s)
      

  5.   

    怎么会有两个&?
    var s=window.location.search;
    s=s.replace(/commandname=[^&]*/gi,"").replace(/&&/gi,"&");