Get The Current Domain Name With Javascript (Not the path, etc.)


 

If you wish a full domain origin, you can use this:

document.location.origin

And if you wish to get only the domain, use can you just this:

document.location.hostname

But you have other options, take a look at the properties in:

document.location


Reference:
https://stackoverflow.com/questions/11401897/get-the-current-domain-name-with-javascript-not-the-path-etc/11401921


Article ID: 45
Created On: Fri, Oct 2, 2020 at 9:16 AM
Last Updated On: Fri, Oct 2, 2020 at 9:16 AM
Authored by: Saeed Nobakht [[email protected]]

Online URL: https://www.navel.ir/article/get-the-current-domain-name-with-javascript-not-the-path-etc-45.html