在 JavaScript 中更改父路径时重定向到 URL
我有一个网址:
http://domain/request.php?id=123
现在在这个网站上我有一个带有提交处理程序的按钮,应该重定向到
http://domain/submit_solution#/?id=123
我尝试过这个:
$('#r_submit_form').click(function()
{
window.location = 'submit_solution#/?id=' + $(this).attr('name');
});
但是我没有重定向到
http://domain/submit_solution#/?id=123
它,只是附加
http://domain/request.php?id=123?123=Submit+solution
我尝试了 window.location.href.replace 的各种变体但我找不到一种方法来更改整个网址,而不仅仅是向其附加另一部分。怎么办呢?
request.php的重写规则是
RewriteRule ^(request|profile|profile_picture|solution|payment)/([0-9]+)$ /$1.php?id=$2 [L] –
I have an url:
http://domain/request.php?id=123
Now on this site I have a button with a submit handler that is supposed to redirect to
http://domain/submit_solution#/?id=123
I tried this:
$('#r_submit_form').click(function()
{
window.location = 'submit_solution#/?id=' + $(this).attr('name');
});
But instead of redirecting to
http://domain/submit_solution#/?id=123
it just appends
http://domain/request.php?id=123?123=Submit+solution
I have tried all kinds of variants with window.location.href.replace but I cant find a way to change the whole url and not just append another part to it. How can it be done?
The rewrite rule for request.php is
RewriteRule ^(request|profile|profile_picture|solution|payment)/([0-9]+)$ /$1.php?id=$2 [L] –
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它附加是因为您应该在 window.location 中使用整个域:
It appends because you should use the whole domain in your window.location:
window.location 有您需要的信息:
window.location has the information you need: