Javascript get domain name, port etc..

By.

min read

My profile

Share this:

[code:1:53de74411e]location = {
host: “stackoverflow.com”,
hostname: “stackoverflow.com”,
href: “http://stackoverflow.com/questions/2300771/jquery-domain-get-url”,
pathname: “/questions/2300771/jquery-domain-get-url”,
port: “”,
protocol: “http:”
}[/code:1:53de74411e]

So .. use:
[code:1:53de74411e]location.protocol + “//” + location.host[/code:1:53de74411e]

Source: http://stackoverflow.com/questions/2300771/jquery-domain-get-url/13509716?stw=2#13509716

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *