我如何 link 从外部 link 到模态对话框?
How do I link to a modal dialog from an external link?
我的网站有一个模式付款表格。我想要的只是(对于某些特定客户)向他们传递一个 link 并且当他们单击它以移动到已经打开模式的网站时。
这可能吗?
您必须自己促进该功能。假设您有这样的正常 bootstrap 模态:
<div class="modal fade" id="payment">
<div class="modal-dialog">
<div class="modal-content">
...
</div>
</div>
</div>
并且您想在发送给某些用户的 link 中调用页面加载模式:
然后将这段代码添加到您的页面中:
$(document).ready(function() {
var modals = ['#payment', '#anotherModal'];
if (window.location.hash && ~modals.indexOf(window.location.hash)) {
$(window.location.hash).modal();
}
})
这当然是迄今为止最简单的方法。
我的网站有一个模式付款表格。我想要的只是(对于某些特定客户)向他们传递一个 link 并且当他们单击它以移动到已经打开模式的网站时。 这可能吗?
您必须自己促进该功能。假设您有这样的正常 bootstrap 模态:
<div class="modal fade" id="payment">
<div class="modal-dialog">
<div class="modal-content">
...
</div>
</div>
</div>
并且您想在发送给某些用户的 link 中调用页面加载模式:
然后将这段代码添加到您的页面中:
$(document).ready(function() {
var modals = ['#payment', '#anotherModal'];
if (window.location.hash && ~modals.indexOf(window.location.hash)) {
$(window.location.hash).modal();
}
})
这当然是迄今为止最简单的方法。