How is the showModalDialog method used in JavaScript?

In JavaScript, the showModalDialog method is used to display a modal dialog box. A modal dialog box is a pop-up window where the user must complete an action before closing the dialog. This method takes three parameters: URL, parameters, and features.

Syntax:

showModalDialog(URL, 参数, 特性);

Example:

var result = window.showModalDialog('popup.html', 'dialogWidth:400px; dialogHeight:200px; center:yes; resizable:no');

In the example above, ‘popup.html’ is the URL of the page to be displayed in a modal dialog, and ‘dialogWidth:400px; dialogHeight:200px; center:yes; resizable:no’ is the string defining the dialog properties.

It’s important to note that the showModalDialog method has been deprecated in HTML5. It is recommended to use the window.open method or a third-party library to achieve similar functionality.

Leave a Reply 0

Your email address will not be published. Required fields are marked *