2

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
2
  • 6
    did you even bother to google that before asking? Commented Sep 17, 2010 at 8:36
  • 1
    Haters are hating again - damnit people... just be nice... You get points for asking/answering questions here.. Google doesn't give you points :P Commented Sep 17, 2010 at 11:31

3 Answers 3

14

Use this:

var url = window.location.protocol + "//" + window.location.host;
answered Sep 17, 2010 at 8:38
0
2
window.location.hostname
answered Sep 17, 2010 at 8:34
0
1

try

window.location.protocol+'//'+window.location.hostname
answered Sep 17, 2010 at 8:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.