Web Hosting Talk







View Full Version : Use javascript to get *only* the hostname?


mrzippy
11-11-2004, 02:21 AM
Anyone know how to do this?

I have the following javascript:

document.write(location.href);

But this writes the entire URL. (ie: http://www.webhostingtalk.com/)

I only want to get the hostname. (ie: www.webhostingtalk.com)

Thanks!

Burhan
11-11-2004, 03:03 AM
Use document.write(location.hostname)