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

查看:19
本文介绍了在 Bootstrap 模式上打开 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.

关于如何做的任何信息

推荐答案

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

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

您还可以(这可能是一个更好的选择)向用户必须单击的按钮添加 onclick 处理程序(因为 hidden.bs.modal当用户按下 Esc 或单击 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 模式上打开 URL 关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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