在Bootstrap Modal上打开URL关闭 [英] Open URL on Bootstrap Modal close

查看:172
本文介绍了在Bootstrap Modal上打开URL关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我在这里脑子死了,但我正在尝试做似乎应该很容易的事情.

Maybe I'm brain dead here, but I'm trying to do what seems should be an easy thing.

我正在使用Bootstrap在页面加载时打开模式,具体取决于特定变量的值.这一切都很好.但是,当模式打开并且用户单击确定"(大概在阅读了信息文本之后)时,我想翻页以重定向到新页面.我似乎不知道该怎么做.

I am using Bootstrap to open a modal on page load depending on the value of specific variables. This all works great. However, when the modal opens and the user clicks ok (presumably after reading the info text), I want to page to redirect to a new page. I can't seem to figure out how to do this.

有关如何操作的任何信息

Any info on how to do

推荐答案

$(".modal").on("hidden.bs.modal", function () {
    window.location = "your-url";
});

http://getbootstrap.com/javascript/#modals-usage

您还可以(这可能是一个更好的选择)向用户必须单击的按钮添加onclick处理程序(因为当用户通过按下Esc关闭模式时,也会触发hidden.bs.modal事件)或单击x按钮.

You could also (and that is probably a better option) add a onclick handler to the button that the user has to click (because the hidden.bs.modal event also fires when the user closes the modal by pressing Esc or clicking the x button.

这篇关于在Bootstrap Modal上打开URL关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆