How to get Domain name from URL using jquery..?

后端 未结 10 984
一生所求
一生所求 2020-12-02 10:01

I have domain name for eq.

1) http://www.abc.com/search 
2) http://go.abc.com/work

I get only domain name from the above URL

Output

10条回答
  •  抹茶落季
    2020-12-02 10:21

    To get the url as well as the protocol used we can try the code below.

    For example to get the domain as well as the protocol used (http/https).

    https://google.com

    You can use -

    host = window.location.protocol+'//'+window.location.hostname+'/';

    It'll return you the protocol as well as domain name. https://google.com/

提交回复
热议问题