window.location.host

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
moiseszaragoza
Forum Commoner
Posts: 87
Joined: Sun Oct 03, 2004 4:04 pm
Location: Ft lauderdale
Contact:

window.location.host

Post by moiseszaragoza »

I was wandering if i can get the host name of a web address that i am going to


for example

Code: Select all

var=http://www.mysite.com/pages/thispage.php

 newVar= window.location.host (var); 
window.alert(newVar) // http://www.mysite.com/
Thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I think it would be just

window.alert(window.location.host)
(#10850)
User avatar
moiseszaragoza
Forum Commoner
Posts: 87
Joined: Sun Oct 03, 2004 4:04 pm
Location: Ft lauderdale
Contact:

Post by moiseszaragoza »

Thanks
User avatar
DaveTheAve
Forum Contributor
Posts: 385
Joined: Tue Oct 03, 2006 2:25 pm
Location: 127.0.0.1
Contact:

Post by DaveTheAve »

ha ha.... [url]javascript:window.alert(window.location.host);[/url] ... sorry I had too.
Post Reply