[英]how to close popup window from asp.net mvc
I want to close some html popup windows.我想关闭一些 html 弹出窗口。 I have static site, which creates popup windows.
我有静态站点,它创建弹出窗口。 These windows have a submit button, which sends a POST request to asp mvc app.
这些窗口有一个提交按钮,它向 asp mvc 应用程序发送 POST 请求。 This app works well and return View() (Index page with message "Ok". And Button "Close").
这个应用程序运行良好并返回 View() (带有消息“Ok”的索引页面。和按钮“Close”)。
When I click on Close button- nothing happens.当我点击关闭按钮时 - 没有任何反应。
My code:我的代码:
<body>
<button type="button" id="btn" onclick="window.parent.jQuery('#btn, #m_window').hide('slow');">Close</button>
<!-- <button type="button" id="btnFoo" onclick="$("#btnFoo, #m_frame").live("click", function(){
$("#mistake").remove();
}); ">Close form </button>
-->
</body>
m_frame- frame of popup window. m_frame- 弹出窗口的框架。 mistake- div of popup window.
错误 - 弹出窗口的 div。
Please, tell me how to close this popup window?请告诉我如何关闭这个弹出窗口?
window.close()
doesn't work. window.close()
不起作用。
PS at js script (when popup creates) I write: PS at js 脚本(当弹出窗口创建时)我写:
$("#btn",#m_window").live("click",function(){
var p = parent;
var win = p.document.getElementById('mistake');
win.parentNode.removeChild(win);
});
But it doesn't works too.但它也不起作用。
Try this尝试这个
<script>
$(document).ready(function () {
$("#displayinmodal").dialog({
autoOpen: true,
modal: true,
buttons: {
"Close": function () {
$("#displayinmodal").dialog("close");
}
}
});
});
</script>
<div id="displayinmodal">
Popup demo
</div>
你应该试试:
window.close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.