jquery, domain, get URL

前端 未结 11 2080
滥情空心
滥情空心 2020-12-12 10:04

How can I get the domain name with jquery ??

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 10:52

    //If url is something.domain.com this returns -> domain.com
    function getDomain() {
      return window.location.hostname.replace(/([a-zA-Z0-9]+.)/,"");
    }
    

提交回复
热议问题