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 ...