views:

70

answers:

3

Hi,

I want to get the url with javascript. But I just need http://www.mysite.com, without any parameters behind it. any idea how to get that?

+2  A: 
window.location.hostname
dfens
ok, that just returns www.mysite.com but I can prepend http:// to it
ArtWorkAD
yes, just add what you need :)
dfens
+12  A: 

Use this:

var url = window.location.protocol + "//" + window.location.host;
Residuum
+1 for HTTPS support!
elusive
@elusive - I second that!
Neurofluxation
+1  A: 

try

window.location.protocol+'//'+window.location.hostname
Yogesh