能否传到服务器端呢?因为我要转化成字符串进行处理。
比如:“http://expert.csdn.net/Expert”,对我有用的只是“expert.csdn.net”

解决方案 »

  1.   

    //strPath就是你要的字符串
    var strPath = location.href;
      

  2.   

    var strURL=window.location.href;或者
    var strURL=window.location.pathname;
      

  3.   

    可以在页面初始化时把地址赋给一个隐藏控件,这样提交时就可以把地址提交给服务器端了
    <body>
    <input type="hidden" id="h" value="">
    </body>
    <script language="javascript">
    h.value=location.href;
    </script>
      

  4.   

    <script language="javascript">
      var strUrl = window.location.href;
      strUrl = strUrl.split("http://")[1].split("/")[0]
      alert(strUrl);
    </script>