Advertisement
Guest User

Untitled

a guest
Sep 27th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. alert(document.domain);
  2.  
  3. location.host
  4.  
  5. function getHost(url)
  6. {
  7. var a = document.createElement('a');
  8. a.href = url;
  9. return a.hostname;
  10. }
  11.  
  12. location = {
  13. host: "stackoverflow.com",
  14. hostname: "stackoverflow.com",
  15. href: "http://stackoverflow.com/questions/2300771/jquery-domain-get-url",
  16. pathname: "/questions/2300771/jquery-domain-get-url",
  17. port: "",
  18. protocol: "http:"
  19. }
  20.  
  21. location.host
  22.  
  23. location.protocol + "//" + location.host
  24.  
  25. document.domain
  26.  
  27. //If url is something.domain.com this returns -> domain.com
  28. function getDomain() {
  29. return window.location.hostname.replace(/([a-zA-Z0-9]+.)/,"");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement