我的问题是我想通过 JavaScript 重定向到上面的目录。
My code:
location.href = (location.href).substr(0, (location.href).lastIndexOf('folder'))
网址如下所示:
example.com/path/folder/index.php?file=abc&test=123&lol=cool
重定向仅影响以下内容:
example.com/path/&test=123&lol=cool
但想要拥有这个:
example.com/path/
我该怎么做?
您可以进行相对重定向:
window.location.href = '../'; //one level up
or
window.location.href = '/path'; //relative to domain
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)