Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alert(document.domain);
- location.host
- function getHost(url)
- {
- var a = document.createElement('a');
- a.href = url;
- return a.hostname;
- }
- 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
- location.protocol + "//" + location.host
- document.domain
- //If url is something.domain.com this returns -> domain.com
- function getDomain() {
- return window.location.hostname.replace(/([a-zA-Z0-9]+.)/,"");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement