我有一个网址:
'/toto/errorSubmitForm/'
我有一个带关闭按钮的模式,当我单击带有此代码的关闭按钮时,该链接会重定向到其他URL
function clickCloseModal() {
$('#closeModal').click(function(evt){
evt.preventDefault();
window.location.href = "/toto/";
});
}
但是,当我在模态之外单击时,我离开了模态,然后我也搜索了重定向它。当我那样更改ID但没有用时,我会尝试这样做。
var modal = document.getElementById('myModal');
window.onclick = function(event) {
if (event.target == modal) {
window.location.href = "/toto/";
}
}
我给你我模态的开始
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
答案 0 :(得分:0)
You should handle the event on closing modal so that you can redirect to the specified url:
$('#myModal').on('hidden.bs.modal', function () {
window.location.href = "/toto/";
})