Home > Web Front-end > JS Tutorial > body text

Introduction to window.returnValue usage examples_javascript skills

WBOY
Release: 2016-05-16 16:42:39
Original
1325 people have browsed it

window.showModalDialog is a method to pop up a modal window

returnValue is an attribute of the window object of HTML in JavaScript. The purpose is to return the window value. When using the window.showModalDialog function to open a modal window of IE (you know the modal window, you cannot operate the parent window after opening it, you can only wait for the mode (can only be operated when the window is closed), it is used to return the value of the window. Here is an example:

1. parent.html

//father.html 
<HTML> 
<HEAD> 
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> 
<TITLE></TITLE> 
<script language="javascript"> 

function showmodal(){ 
var ret = window.showModalDialog("child.htm",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no"); 
if (ret){alert('子窗口返回真!'); 
}else{ 
alert('子窗口返回假!'); 
} 
} 
</script> 
</HEAD> 

<BODY> 
<INPUT id=button1 type=button value=Button name=button1 onclick="showmodal();"> 
</BODY> 
</HTML>
Copy after login

2. child.html

//child.html 
<HTML> 
<HEAD> 
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> 
<TITLE></TITLE> 
<script language="javascript"> 
function trans(tag){ 
if (tag==0){ 
window.returnValue=false; 
} else{ 
window.returnValue =true; 
} 
window.close(); 
} 
</script> 
</HEAD> 
<BODY> 

<INPUT id=button1 type=button value="返回真" name=button1 onclick="trans(1)"> 
<INPUT id=button2 type=button value="返回假" name=button2 onclick="trans(0)"> 

</BODY> 
</HTML>
Copy after login

Summary:

In this way, the value can be transferred from the modal window to the parent window. In addition to Boolean values, integer values, etc., the returnValue can also be a js array, used to transfer large amounts of data.

For specific usage of showModalDialog, etc., please refer to msdn.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template