The showModelessDialog dialog box is unique and closes with the parent page. The ios mode dialog box appears.

Source: Internet
Author: User

The showModelessDialog dialog box is unique and closes with the parent page. The ios mode dialog box appears.

During website development, forms are often displayed. the pop-up dialog box contains modal and non-modal modes, as shown below:

Mode: window. showModalDialog ()

Non-modal: window. showModelessDialog ()

In addition, the window. open Method and the form of simulating the pop-up box effect through div.

Window. open your own Baidu, learn not deeply; div simulation method is not applicable and, in the pop-up box, some components are incompatible with the parent page components, such as the project where the author is located, jquery on the parent page is incompatible with the js framework of the entire website (of course, it is not simple to replace the $ keyword ). So I chose the window. showModelessDialog () method. However, if you use this method, you may encounter the problem of opening multiple pop-up boxes and not closing the parent page after it is closed. The key to solving this problem is,The window. showModelessDialog () method returns the page object to be opened., You only need to cache this page object. When you open the page again, you can determine the status of this object.

The Code is as follows:

1 if (! ModelessDialog | modelessDialog. closed) {2 modelessDialog = window. showModelessDialog (

This prevents multiple pop-up boxes from being opened.

To disable a child page synchronously with the parent page, you only need to disable the child page in the onUnload of the parent page.

The Code is as follows:

1 // parent page: 2 <body> 3 4 // when the parent page is closed, close and right-click search screen 5 function modelessDialog_Close () {6 if (modelessDialog &&! ModelessDialog. closed) {7 modelessDialog. close (); 8 modelessDialog = null; 9} 10}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.