How to get current URL with JavaScript?

This question already has an answer here:

  • Get current URL in JavaScript? 29 answers

  • If you are currently on http://store.ijdmtoy.com/abs.htm then document.URL will be http://store.ijdmtoy.com/abs.htm .

    You can try:

    url = location.protocol + '//' + location.host + location.pathname + '?Search=' + str;


    You can use

          document.URL  or
          window.location.href.toString()
    

    I hope you mean this

    http://jsfiddle.net/AmarnathRShenoy/q3yCA/


    Use this code document.URL

    Ex:

    alert(document.URL);
    

    You can get path slit like

    var split=document.URL.split("/");
    
    链接地址: http://www.djcxy.com/p/70236.html

    上一篇: 如何在JavaScript中获取URL?

    下一篇: 如何使用JavaScript获取当前网址?