简体   繁体   English

JavaScript对话视窗关闭

[英]Javascript dialog window close

I Want to Close window.dialog . 我要关闭window.dialog I open window as below, 我打开窗口如下

window.$('<div align="center" style="width:100%;height:100%;"><iframe src="'+fdt+'" width="100%" height="100%" frameborder="0" scrolling="no"></iframe></div>').dialog({ 
     modal: true,
     width: 460, 
     height: 450,
     title: "Serial"
    });

After open dialog, when press enter key on input I want to close this window. 打开对话框后,当按输入上的Enter键时,我要关闭此窗口。 Please Help me. 请帮我。

$(document).ready(function(){
$('#stsr').keypress(function(e) {
    if(e.keyCode==13){
          //I Want to close this window
    }
});
});

Give the DIV an ID 给DIV一个ID

window.$('<div id="dialog" align="center" style="width:100%;height:100%;"><iframe src="'+fdt+'" width="100%" height="100%" frameborder="0" scrolling="no"></iframe></div>').dialog({ 
     modal: true,
     width: 460, 
     height: 450,
     title: "Serial"
});

Then you can refer to it later: 然后您可以稍后参考它:

$(document).ready(function(){
    $('#stsr').keypress(function(e) {
        if(e.keyCode==13){
            $("#dialog", window.parent.document).dialog("close");
        }
    });
});

Probably the same question here . 这里可能是同样的问题。 window.close() should do the trick: window.close()应该可以解决问题:

if(e.keyCode==13){
      close();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM