![](/img/trans.png)
[英]Bootstrap AngularJS modal redirecting the user properly, but the page looks blacked out
[英]Redirecting a user to a page that opens a modal
当我需要将用户重定向到其他页面并在该页面上打开模式时,我使用以下方法:
var qsData = parseQueryString();
var showModal = ("show-modal" in qsData);
if (showModal) {
// Load the modal and change the url back to the base url
var modalToDisplay = qsData['show-modal'];
$(`a[data-modal-body-id="${modalToDisplay}"]`).click();
window.history.pushState({}, null, window.location.href.split('?')[0]);
}
这样,我可以传递一个网址,例如:
它将为他们打开“更改密码”模式。 在执行此重定向时,我需要完成两件事:
做到这一点的最佳方法是什么? 也就是说,更改url但不将其存储在历史记录中吗? 我当时在考虑使用会话变量,但是我认为这不起作用,因为有时url链接会出现在电子邮件中,因此有时我没有'state'开头。
你应该尝试使用
window.history.replaceState({}, null, window.location.href.split('?')[0]);
这不会将新状态添加到堆栈中。 它将替换当前的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.