UW Madhu
UW Madhu

Reputation: 3

Javascript dialog window close

I Want to Close 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. Please Help me.

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

Upvotes: 0

Views: 114

Answers (2)

Barmar
Barmar

Reputation: 780723

Give the DIV an 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");
        }
    });
});

Upvotes: 1

2ooom
2ooom

Reputation: 1760

Probably the same question here. window.close() should do the trick:

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

Upvotes: 0

Related Questions