我有一个网址http://xyz.in/pqr/v/index.php我只想得到 http://xyz.in/pqr/v/那么如何从 url 中删除 index.php。
最佳答案
试试这个。
var host = window.location.protocol+'//'+window.location.host+'/'
alert(host);
如果你想最后避免'/',你可以使用这个
var host2 = window.location.protocol+'//'+window.location.host
查看此FIDDLE DEMO
关于javascript - 使用 jquery 获取基本 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20878368/