Home > Web Front-end > JS Tutorial > JavaScript method to implement parameter passing in browser window_javascript skills

JavaScript method to implement parameter passing in browser window_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:37:25
Original
1296 people have browsed it

a.html

<html> 
<head> 
<title>主页面</title> 
<script language="javascript" type="text/javascript"> 
function OpenNew() 
{ 
var im=new IDAndMethod(); 
im.ID=document.getElementById("txtID").value; 
window.showModalDialog("ddd.html",im,""); 
} 
function IDAndMethod() 
{ 
this.ID="ddd"; 
this.Method=SetTxt; 
} 
function SetTxt(str) 
{ 
document.getElementById("txtID").value=str; 
} 
</script> 
</head> 
<body> 
<form action="#"> 
<input id="txtID" style="width:400px" type="text" value="XXX!在这里输入ID!" /><br /> 
<input type="button" value="打开新的窗口" onclick="OpenNew()" /> 
</form> 
</body> 
</html>
Copy after login

 b.html

<html> 
<head> 
<title>主页面</title> 
<script language="javascript" type="text/javascript"> 
var im; 
function Load() 
{ 
im=window.dialogArguments; 
if(im.ID=="XXX!在这里输入ID") 
document.getElementById("txtID1").value="你杂不输入呢!"; 
else 
document.getElementById("txtID1").value=im.ID; 
} 
function Set() 
{ 
im.Method(document.getElementById("txtID1").value); 
} 
</script> 
</head> 
<body onload="Load()"> 
<form action="#"> 
<input id="txtID1" style="width:400px" type="text" value="ddd" /><br /> 
<input type="button" value="传递数据" onclick="Set()" /> 
</form> 
</body> 
</html>
Copy after login
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