How to get current URL using javascript

This question already has an answer here:

  • Get the current URL with JavaScript? 18 answers

  • 这是正确的答案:

    window.location.host + window.location.pathname;
    

    You want this:

    var location = window.location.host + window.location.pathname;
    

    see the docs: https://developer.mozilla.org/en-US/docs/Web/API/Location

    链接地址: http://www.djcxy.com/p/22538.html

    上一篇: 在javascript函数中使用当前网址

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