作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用对话框模式在我的网页上显示条款和条件。但在按钮上不同意,在调用函数 window.close 时,网页不会关闭。
我想在单击不同意按钮后关闭最近的页面
下面粘贴的是我遇到问题的示例代码。
<script>
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:600,
width:400,
modal: true,
buttons: {
'Agree': function() {
$( this ).dialog( window.location.assign('../mdv/main.php') );
},
'Disagree': function() {
$( this ).dialog( window.close() );
}
}
});
});
</script>
提前谢谢您。
最佳答案
你这样做:
<script>
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:600,
width:400,
modal: true,
buttons: {
'Agree': function() {
$( this ).dialog( window.location.assign('../mdv/main.php') );
},
'Disagree': function() {
$( this ).dialog("close");
}
}
});
});
</script>
您可以使用上面的代码关闭对话框本身,或者如果它是之前通过 JavaScript 打开的弹出窗口,则可以关闭该窗口。在这种情况下,您将需要该引用来调用 close 方法。
但是,您无法使用 JavaScript 关闭整个网页/选项卡,这是 JavaScript 的限制。正如我提到的,只有之前使用 JavaScript 打开过它,您才能将其关闭。
关于javascript - window.close() 在 Jquery 模态中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31749702/
我来自 Asp.Net 世界,试图理解 Angular State 的含义。 什么是 Angular 状态?它类似于Asp.Net中的ascx组件吗?是子页面吗?它类似于工作流程状态吗? 我听到很多人
我一直在寻找 3 态拨动开关,但运气不佳。 基本上我需要一个具有以下状态的开关: |开 |不适用 |关 | slider 默认从中间开始,一旦用户向左或向右滑动,就无法回到N/A(未回答)状态。 有人
我是一名优秀的程序员,十分优秀!