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?

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;
Sign up to request clarification or add additional context in comments.

Comments

2
window.location.hostname

Comments

1

try

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

Comments

Your Answer

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.