Home  >  Article  >  Web Front-end  >  Introduction to window.returnValue usage examples_javascript skills

Introduction to window.returnValue usage examples_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:42:391330browse

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>

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>

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.

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