我有个问题:
location.href = (location.href).substr(0, (location.href).lastIndexOf('folder'));
URL如下所示:
实例com/path/folder/index.php?文件=abc&;测试=123&;lol=酷
重定向只会影响以下内容:
实例com/path/&;测试=123&;lol=酷
但我想要这个:
实例com/path/
我怎么能这么做呢?
我有个问题:
location.href = (location.href).substr(0, (location.href).lastIndexOf('folder'));
URL如下所示:
实例com/path/folder/index.php?文件=abc&;测试=123&;lol=酷
重定向只会影响以下内容:
实例com/path/&;测试=123&;lol=酷
但我想要这个:
实例com/path/
我怎么能这么做呢?
您可以执行相对重定向:
window.location.href = '../'; //one level up
或
window.location.href = '/path'; //relative to domain