window.open and window.showModalDialog differences:
1. All open a new window on IE, but the former is non-blocking, also can be said non-modal window. The latter is a blocking modal window. Block or modal window, you can only go to the Father window after you close the current window.
2. On the parameters:
Onewwindow window . Open ( [surl] [sName] [ sfeatures] [breplace]) Opens a new window and loads the document for the given URL. return value: Returns the open new Window object surl: Optional parameter, to open the address of the new window Url.sname: Optional parameters, the new window handle name, commonly used four kinds are: _blank,_parent,_top,_self.sfeatures: Optional parameters, IE window related features, there are Height,width,left.top,location,menubar,resizable,scrollbars,status,titlebar,toolbar, and Channelmode, Directories and fullscreen (full-screen mode) special parameters. Sreplace: Optional parameter Example:window.open ("sample.htm", NULL, "height=200,width=400, Status=yes,toolbar=no,menubar=no,location=no ");
window.showModalDialog () Creates a modal dialog box that displays the specified HTML document.
Vreturnvalue window . ShowModalDialog (surl [varguments] [ sfeatures ]) sURL: Optional parameter, to open the address of the new window url.varguments: Optional parameter, which can be used to pass parameters to the child window. Used to pass parameters to the dialog box. There are no limits on the types of arguments passed, including arrays. The dialog box uses window.dialogarguments to get the arguments passed in. This parameter is hidden and is not placed in the URL, which improves security. sfeatures: Optional parameters, Dialogheight,dialogwidth,dailogleft,dialogtop,center,dialoghide,edge,help,resizable,scroll , status,unadorned.
parameter passing: 1. To pass a parameter to a dialog box, it is passed by Varguments. Type is not limited, for string types, the maximum is 4,096 characters. You can also pass objects, for example:-------------------------------parent.htm <script> var obj = new Object (); Obj.name= "51js"; window.showModalDialog ("modal.htm", obj, "dialogwidth=200px;dialogheight=100px"); </script> modal.htm <script> var obj = window.dialogarguments alert ("You pass parameters:" + obj.name) </script>-- -----------------------------2. You can return information by Window.returnvalue to the window that opens the dialog box, or it can be an object. For example:------------------------------parent.htm <script> str =window.showmodaldialog ("modal.htm",, "dialogwidth= 200px;dialogheight=100px "); alert (str); </script> modal.htm <script> window.returnvalue= "http://www.web3.cn"; </script>
3. Reference security: 1) window.open (), by creating a form submission, submitted by post, parameter parameters are safe. As follows: function Openpostwindow (URL, data, name) {var tempform = document.createelement ("form"); tempform.id= "TempForm1"; Tempform.method= "POST"; Tempform.action=url; Tempform.target=name; var hideinput = document.createelement ("input"); Hideinput.type= "hidden"; Hideinput.name= "Content" hideinput.value= data; Tempform.appendchild (Hideinput); Tempform.attachevent ("onsubmit", function () {Openwindow (name);}); Document.body.appendChild (Tempform); Tempform.fireevent ("onsubmit"); Tempform.submit (); Document.body.removeChild (Tempform); } function Openwindow (name) {window.open (' About:blank ', name, ' height=400, width=400, Top=0, left=0, Toolbar=yes, Menubar=yes, Scrollbars=yes, Resizable=yes,location=yes, Status=yes '); }2). window.showModalDialog, pass the parameter through the second parameter varguments, and then in the child page, then use the parameters passed by window.dialogarguments:
(turn) The difference between window.open and window.showModalDialog