在我的 MVC5 应用程序中,我打开一个如下所示的弹出窗口:
<script type="text/javascript">
function openNewWindow(e) {
e.preventDefault();
window.open("/Index/PopUp", "New Window", "height=700,width=500");
return false;
}
</script>
In the pop-up I made a selection on some data & want a to return a view model to the previous view - is this possible?
我开始认为使用弹出窗口可能不是最好的主意,但我有兴趣了解任何可能的解决方案......
最佳答案
为打开的窗口
分配全局引用,使用.close()
关闭打开的窗口
。
<script type="text/javascript">
window.popup = void 0;
function openNewWindow(e) {
e.preventDefault();
window.popup = window.open("/Index/PopUp", "New Window", "height=700,width=500");
return false;
}
// do stuff after call to `openNewWindow`
// close `window.popup`
// window.popup.close();
</script>
关于javascript - 如何关闭弹出窗口并将 View 模型返回到先前的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41163008/