Monday 27 October 2008

Modal Popup in IE

To have a web page popup in a modal page IE has a javascript function

window.showModalDialog('page url', 'page title', 'options');

The syntax for the options is slightly different from window.open

To specify height and width we would do:

'dialogHeight:300px; dialogWidth:300px'

To make sure the code works cross browser we can check for the showModalDialog function and if it is not available we can you use window.open.

eg.

if (window.showModalDialog)
{
window.showModalDialog('page.html','MyPage','dialogWidth:300px;dialogHeight:3000px');
}else{
window.open('page.html','MyPage','width=300, height=300');
}

1 comment:

Andy said...

showModalDialog()

is supported in Firefox 3

Free Hit Counter