Window. open () and window. Opener

Source: Internet
Author: User
File1.php page, JavaScript code
<script type="text/javascript" src="JQuery/jquery-1.5.1.js"></script>
<script type="text/javascript">
function dianJi(){
//window.open("file2.php","file2","height=100,width=400,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
window.open("file2.php","file2","height=500,width=800,top=100,left=100,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}

function back_db(db2){
$("input[name='text2']").val(db2);
}
</script>

 
"File2.php" pop-up window path and file name

The name of the "file2" pop-up window. It is also the handle (not the file name) of the pop-up window. It is optional and can be empty.

Height window height

Width window width

Pixel value of the top window above the screen

Pixel value left from the left side of the screen

Toolbar = No indicates whether to display the toolbar. Yes indicates display.

Menubar indicates the menu bar

Scrollbars indicates the scroll bar

Resizable = No whether to change the window size, yes is allowed

Location = No whether the address bar is displayed, yes is allowed

Status = No whether to display the information in the status bar (usually the file has been opened) yes

The attributes after the name "file2" in the pop-up window are put in a double quotation mark and separated by commas. One or more attributes can be used.

HTML code

<Input type = "button" onclick = "dianji ()" value = "Trigger"/>
<Input type = "text" id = "text1" value = "Hello world! "/>
<Input type = "text" name = "text2" value = "Hello! "/>

 

On the file2.php page, you can add the following JavaScript code to disable file2.php automatically after a certain period of time, and use window. opener to call the method in file1.php page JS and directly change the file1.php page element value.

<SCRIPT type = "text/JavaScript">
Function closeit (){
SetTimeout ("tiaozhuan ()", 10000); // setTimeout () the method in the first parameter is run only once after the specified time, in milliseconds
// Setinterval ("tiaozhuan ()", 10000); // setinterval () runs once every specified time and cyclically, in milliseconds
}

Function tiaozhuan (){
VaR db1 = "Hello world! ";
VaR DB2 = "Hello! ";
Optional values opener.doc ument. getelementbyid ("text1"). value = db1;
Window. opener. back_db (DB2 );
Window. Close ();
}
</SCRIPT>

 

HTML code

<Body onload = "closeit ()">
... Automatically shut down in 10 seconds
</Body>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.