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?
asked Sep 17, 2010 at 8:32
-
6did you even bother to google that before asking?Stefanvds– Stefanvds2010年09月17日 08:36:32 +00:00Commented Sep 17, 2010 at 8:36
-
1Haters are hating again - damnit people... just be nice... You get points for asking/answering questions here.. Google doesn't give you points :PBarrie Reader– Barrie Reader2010年09月17日 11:31:07 +00:00Commented Sep 17, 2010 at 11:31
3 Answers 3
Use this:
var url = window.location.protocol + "//" + window.location.host;
answered Sep 17, 2010 at 8:38
window.location.hostname
answered Sep 17, 2010 at 8:34
try
window.location.protocol+'//'+window.location.hostname
answered Sep 17, 2010 at 8:41
lang-js