Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get url with javascript

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?

like image 459
UpCat Avatar asked Jun 27 '26 20:06

UpCat


2 Answers

Use this:

var url = window.location.protocol + "//" + window.location.host;
like image 170
Residuum Avatar answered Jun 29 '26 13:06

Residuum


window.location.hostname
like image 31
dfens Avatar answered Jun 29 '26 12:06

dfens