We can get the hostname of the current page by using location object , Here is the example.
Sample code is here.
The output is here
Refresh the page
Subscribe to our YouTube Channel here
This article is written by plus2net.com team.