The ShowModalDialog of IE and FireFox

Source: Internet
Author: User
Tags window

In the Web page program,
Sometimes we want the user to press the button and open a child window that stays in front of the original window.
And in IE, we can use ShowModalDialog to achieve,
The syntax is as follows:


Vreturnvalue = window.showModalDialog (sURL [, varguments] [, Sfeatures])


Example:


window.showModalDialog ("openwin.html", "Arguments", "dialogheight:200px; dialogwidth:200px; dialogtop:10px; dialogleft:10px; edge:raised; Center:yes; Help:yes; Resizable:yes; Status:yes; ");


But there's no showmodaldialog in Firefox,
And in Firefox we can only use window.open to achieve this function,
The syntax for window.open is as follows:


Onewwindow = window.open ([sURL] [, sname] [, Sfeatures] [, Breplace])


Just, in Firefox, window.open's parameters, sfeature a number of features set,
And in Firefox to let open windows and IE showmodaldialog the same words,
Just add a modal=yes to the sfeatures.
Examples are as follows:


window.open (' openwin.html ', ' newwin ', ' modal=yes,width=200,height=200,resizable=no,scrollbars=no ');


Referring to the child window, it is necessary to mention the child window and the parent window interaction between the operation,
Because I think a lot of people open the dialogue window should be to the end of the operation of the results thrown back to the mother window ...


If you're using ShowModalDialog,
To access the function of the parent window in the child window,
Two places to pay attention to,
1. (in the parent window) Open the window:


window.showModalDialog ("openwin.html", Self, ' modal=yes,width=775,height=700,resizable=no,scrollbars=no ');


In the second argument (varguments), change to self.


2. (In child window) The function that invokes the parent window:


WINDOW.DIALOGARGUMENTS.SHOWMSG (Obj.value);


ShowMsg is the function in the parent window.



and using window.open words,
is to pay attention to a place,
1. (In child window) The function that invokes the parent window:


WINDOW.OPENER.SHOWMSG (Obj.value);


Use Window.opener to connect to the object of the parent window.


So, as long as the browser is judged by the navigator.appname,
You can write an IE and Firefox-compatible function ...




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.