Usage analysis of javascript window.opener_Basic knowledge
WBOY
Release: 2016-05-16 18:30:22
Original
1211 people have browsed it
Usage of window.opener window.opener returns a reference to the window that created the current window. For example, if you click on a link on a.htm and open b.htm, then we plan to Enter a value on b.htm and assign it to a textbox with the id "name" on a.htm. You can write it as:
I don't have a good understanding of window.opener in javascript. Why can’t it be used in a frame? Why can’t the parent window of a pop-up window be on a page inside the frame? So how to operate the parent window in the frame through a pop-up window?
opener.parent.frames['frameName'].document.all.input1.value Try this:) But when talking about window.opener, we have to say open, these two It is possible to use them together. Window.open() supported environment: JavaScript1.0 /JScript1.0 /Nav2 /IE3 /Opera3
Basic syntax: window.open(pageURL,name,parameters) Where: pageURL is the sub-window path name is the sub-window handle parameters is the window parameters (each parameter is separated by commas)
Example:
After the script is run, page.html will be opened in a new window with a width of 100, a height of 400, 0 pixels from the top of the screen, 0 pixels from the left of the screen, no toolbar, no menu bar, no Scrollbar, not resizable, no address bar, no status bar. The above example involves several commonly used parameters. In addition, there are many other parameters, as shown below: Various parameters Among them, yes/no can also use 1/0; pixel value It is a specific value in pixels. Parameter | Value range | Description alwaysLowered | yes/no | The specified window is hidden behind all windows alwaysRaised | yes/no | The specified window is suspended above all windows depended | yes/ no | Whether to close the parent window at the same time directories | yes/no | whether the directory bar of Nav2 and 3 is visible height | pixel value | window height hotkeys | yes/no | in a window without menu bar CMD safe exit hotkey innerHeight | pixel value | Pixel height of the document in the window innerWidth | pixel value | Pixel width of the document in the window location | yes/no | Whether the location bar is visible menubar | yes/no | Whether the menu bar is visible outerHeight | pixel value | Set the pixel height of the window (including decorative borders) outerWidth | pixel value | Set the pixel width of the window (including decorative borders) resizable | yes/no | Whether the window size is resizable screenX | pixel value | The pixel length of the window from the left edge of the screen screenY | pixel value | The pixel length of the window from the upper edge of the screen scrollbars | yes /no | Whether the window can have a scroll bar titlebar | yes/no | Whether the window title bar is visible toolbar | yes/no | Whether the window toolbar is visible Width | pixel value | The pixel width of the window z-look | yes/no | Whether the window floats above other windows after it is activated
Use functions to control pop-up windows The following is a complete code.
Any page content...
A function openwin() is defined here, and the function content is to open a window. How to call it? Method 1:
A pop-up window appears when the browser reads the page; Method 2:
A pop-up window appears when the browser leaves the page; Method Three: Call with a connection: Open a window
Note: The "#" used is a virtual connection. Method 4: Use a button to call:
How to use window.open to return values to the parent window without using window.showModalDialog. For example: The page AAA.htm uses the window.open method to pop up the page BBB.htm. Select a value on the page BBB.htm, and return the selected value to the parent window AAA.htm after closing the window. After getting the returned value, AAA.htm assigns a value to the text box on this page.
Add the following code to the BBB.htm page: window.opener.document.getElementById("theTextAreaId").value = document.getElemnetById("theSelectId").value;
Usage of window.opener window.opener returns a reference to the parent window that created the current window. For example, clicking a link on a.htm opens b.htm, and then we plan to input on b.htm A value is then assigned to a textbox with the id "name" on a.htm, which can be written as: <script> <BR><!-- <BR>window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no') <BR>//写成一行 <BR>--> <BR></script>window.opener.document.getElementById("name").value = "Input data" ; Don’t have a good understanding of window.opener in javascript. 为什么框架中不能使用,弹出窗口的父窗口不能在框架里面的某个页面呢?那怎样通过弹出窗口操作框架中的父窗口呢? opener.parent.frames['frameName'].document.all.input1.value 即opener这个对象为前一个窗口,可以使用window.opener.document...调用document的相关方法,例如下面的例子,插入一些table行到前一个窗口: function taletoTb(itemStr) { newRow = opener.document.all.itemTb.insertRow(opener.document.all.itemTb.rows.length); rowCnt = opener.document.all.itemTb.rows.length; newCell = newRow.insertCell(); newCell.insertAdjacentHTML('BeforeEnd','
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