3 Responses to “How To Get The Domain From A URL Using JavaScript”
This page contains comments from the How To Get The Domain From A URL Using JavaScript article.
This page contains comments from the How To Get The Domain From A URL Using JavaScript article.

Stephen Cronin is Manager of Online Service Delivery at a Queensland Government department & has been a freelance WordPress developer/consultant since 2007
*Content on this site is my own and is not related to my employer
Hire me - I'm expensive, but I'm very good!
Want a Custom WordPress plugin? See my Services page.
Visit my home page at Userscripts.org.
Just a quick note, you might want to take into consideration ‘https’, for example, https://twitter.com returns https when you use the “Extract” above.
Otherwise, I like it.
It breaks if using protocol agnostic uri:
//ajax.googleapis.com
Thanks for sharing!
Nice script .. but what should i do if i want only the base domain name .. like i want google.com only from http://mail.google.com .