DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> javascript實現浏覽器窗口傳遞參數的方法
javascript實現浏覽器窗口傳遞參數的方法
編輯:關於JavaScript     

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>

 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>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved