how to get the host url using javascript from the current page

后端 未结 7 1923
猫巷女王i
猫巷女王i 2020-12-22 17:20

Given that I\'m on the following page:

http://www.webmail.com/pages/home.aspx

How can I retrieve the host name (\"http://www.webmail.

7条回答
  •  情书的邮戳
    2020-12-22 17:27

    let path = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port;
    

提交回复
热议问题