我想使用JavaScript获取网站的基本网址。我使用如何使用javascript在服务器上获取网站的URL
var pathArray = window.location.pathname.split('/');
var baseURL = window.location.protocol + "//" + window.location.host + "/" + pathArray[1]+'/';
这是工作mysite.com/project1
而不是mysite.com
。
我该如何检查这两个网址?我必须向网址发送ajax请求。
在此先感谢。
请删除PHP标签,这个问题从根本上与PHP无关。 – seanyt123 2014-11-24 08:51:02
可能重复的[在JavaScript中获取当前URL?](http://stackoverflow.com/questions/406192/get-current-url-in-javascript) – IROEGBU 2014-11-24 08:59:49