Remove Domain Name From Url Javascript. As root and base URL respectively. Parsing the Domain From a Url.
It is the second line in the code above that is important. This tutorial I will help you how to access our web page domain name URL and path in a variable and alert these variables in your project. The locationprotocol property is used to return the protocol scheme of the URL along with the final colon.
The locationhostname is used to return the domain name of the URL.
In this example we will use the self URL where the code will run to extract the hostname. Problem with SSL with a sub domain. Function getRootUrl documentgetElementByIdrootresultinnerHTML windowlocationorigin. Get the domain name of a website using JavaScript.