Enter your email address:

feedburner count

window.showModalDialog problem in IE

I'm recently encounter a problem when using showModalDialog in IE. I want to access to parent window, but window was opened by showModaldialog doesn't supply full features like normal window.open method . When using window.open, you have window.opener propery that references to parent window, so you can access all properties / method of parent window. In order to solve this problem, pass window.self second parameter of showModaldialog method. In pop-up dialog, access to parent by dialogArguments object. Follow codes snippet will show you how to display a Modal Window, insert a hyperlink to rich text area , work both on IE and FireFox :

  • In parent page :
function insertHyperLink() {
if (window.showModalDialog)
showModalDialog("insert_link.htm", window.self, "status:false;dialogWidth:312px;dialogHeight:265px");
else {
window.open('insert_link.htm', window, 'width=312, height=265, toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,modal=yes');
  • In child window :
function insertLink() {
var txtText = document.getElementById('txtText');
var txtUrl = document.getElementById('txtUrl');
var txtToolTip = document.getElementById('txtToolTip');
var ddlTarget = document.getElementById('ddlTarget');
var parent;
parent = (window.opener) ? window.opener : dialogArguments;
var url = '' + txtText.value + '';

blog comments powered by Disqus