Created
October 12, 2014 17:30
-
-
Save r4fx/a066d68b376d0226fb67 to your computer and use it in GitHub Desktop.
location, url, hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:" | |
} | |
location.host // would be the domain | |
location.protocol + "//" + location.host // complete first part of the url | |
document.baseURI // gives you the domain + port. It's used if an image tag uses a relative instead of an absolute path | |
document.baseURI + window.location.hash // complete first part of the url + hash, example: http://stackoverflow.com/#section |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment