Home >Web Front-end >JS Tutorial >Usage analysis of showModalDialog in JS_javascript skills

Usage analysis of showModalDialog in JS_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:36:361434browse

Basic introduction:                                                     The

window.showModalDialog() method is used to create a modal dialog box that displays HTML content. (That is, you cannot operate the parent window after it is opened, you can only operate it in the wait mode                                                because you cannot operate the parent window after opening it. The

window.showModelessDialog() method is used to create a non-modal dialog box that displays HTML content. (You can still perform other operations after opening it)

How to use:                                                                    

vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])      

vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])

Parameter description:                                                

sURL     — Required parameter, type: string. Used to specify the URL of the document to be displayed in the dialog box.                                                                           

vArguments - Optional parameters, type: variant. Used to pass parameters to the dialog box. The type of parameters passed is not limited, including arrays, etc. The dialog box obtains the parameters passed in through window.dialogArguments.                                                                           

sFeatures - Optional parameters, type: string. Used to describe the appearance of the dialog box and other information, you can use one or more of the following, separated by semicolons ";".

----------------------------------

Parameter passing:

1. To pass parameters to the dialog box, they are passed through vArguments. There is no limit on the type. For string types, the maximum length is 4096 characters. Objects can also be passed.

parent.html


Copy code

The code is as follows:

document.getElementById("buttonID").onclick = function(){
//Click the "Select Input" button to pop up a dialog box for input selection
window. showModalDialog(sURL,vArguments,sFeatures);
                                                    
children.html





Copy code


The code is as follows:
& lt; body & gt;
& lt; script type = "text/javascript" & gt;
// Click the "Select the input" button, it will display the corresponding value in the text box of the parent window Midtop // Receive objects passed by the parent window
var Fatherwindow = window.dialogarguments; lement.parentnode. nextSibling.firstChild.nodeValue;
                                                                                                                                                                                                                                                           ​
        < ;/script>
                                                                                                                                                                                                                                                                              >                                                                                                 
" value="Select Input" onclick="selectInput(this)" />
                                                                                                                                                                                                                     ;/tr>



Final result:



2. You can use window.returnValue to return information to the window that opens the dialog box. It can be a Boolean value, an integer value, etc. It can also be a js array, and of course it can also be an object.

parent.html





Copy code


The code is as follows:


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn