80 Js Get Domain Name From Url Update

I have a problem in webtrends reporting where the url of the page isn t showing up.
Js get domain name from url. Conversely if there is no subdomain the hostname will not have one either. Return domain. Javascript suggests a bunch of methods that help to get the current url displayed at the address bar.
Window location href returns the href url of the current page. Here is the list of options available to get url and other details using javascript. In the above code we take the hostname from the url split its parts by period and then reverse the list of parts.
All of the methods use the location object contains information about the current url which is a property of the window object provides current page address url and redirects the browser to a new page. The url below is a pop up box containing a form but the current tracking is only capturing up to the and so in the reporting the page name is being displayed as which of course is not correct. If you need to web page url path so you can access web url path use this example.
If you want to get domain name in javascript just use the following code. I do this for the reasons explained above but it also makes the rest of the code simpler. Var url document url.
We then concatenate the first two parts of the hostname actually the last two parts of the hostname but reversed. The protocol domain and port of the current page can be found by two methods. Window location hostname returns the domain name of the web host.
Window location protocol returns the web protocol used http. If we strip it it will always be the first element. Using location protocol location hostname location port methods.