Home >Web Front-end >JS Tutorial >Manipulating the parent window object in JavaScript child window ModalDialog_Basic knowledge
Operating the parent window object in ModalDialog
1. You cannot use window.parent
Window.parent is used to operate in the frame, but cannot be used to operate the parent window object in the dialog box.
2. The correct approach
By passing parameters when calling modaldialog
Example:
Requirement
The parent window page is a.html child window The page is b.html. There is a text box in a.html with the ID test1. Click the button in the opened dialog box to change the text box value of a.html to "subwindow value".
Implementation
When opening the dialog box, pass test1 as a parameter to the sub-window, obtain the parameters in the sub-window, and set the value attribute value of the parameter object (that is, the text object passed in a.html) to "sub-window" Window value"
Note: Only id can be passed here, not name
a.html code is as follows