天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

Javascript 兩個(gè)窗體之間傳值實(shí)現(xiàn)代碼

如我們新建窗體FatherPage.htm:
XML-Code:
復(fù)制代碼 代碼如下:
<script type="text/Javascript">
function OpenChildWindow()
{
window.open('ChildPage.htm');
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="OpenChild" onclick="OpenChildWindow()" />

然后在ChildPage.htm中即可通過window.opener來訪問父窗體中的元素:
XML-Code:
復(fù)制代碼 代碼如下:
<script type="text/Javascript">
function SetValue()
{
window.opener.document.getElementById('txtInput').value
=document.getElementById('txtInput').value;
window.close();
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="SetFather" onclick="SetValue()" />

其實(shí)在打開子窗體的同時(shí),我們也可以對(duì)子窗體的元素進(jìn)行賦值,因?yàn)閣indow.open函數(shù)同樣會(huì)返回一個(gè)子窗體的引用,因此FatherPage.htm可以修改為:
XML-Code:
復(fù)制代碼 代碼如下:
<script type="text/Javascript">
function OpenChildWindow()
{
var child = window.open('ChildPage.htm');
child.document.getElementById('txtInput').value
=document.getElementById('txtInput').value;
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="OpenChild" onclick="OpenChildWindow()" />

通過判斷子窗體的引用是否為空,我們還可以控制使其只能打開一個(gè)子窗體:
XML-Code:
復(fù)制代碼 代碼如下:
<script type="text/Javascript">
var child
function OpenChildWindow()
{
if(!child)
child = window.open('ChildPage.htm');
child.document.getElementById('txtInput').value
=document.getElementById('txtInput').value;
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="OpenChild" onclick="OpenChildWindow()" />

光這樣還不夠,當(dāng)關(guān)閉子窗體時(shí)還必須對(duì)父窗體的child變量進(jìn)行清空,否則打開子窗體后再關(guān)閉就無法再重新打開了:
XML-Code:
復(fù)制代碼 代碼如下:
<body onunload="Unload()">
<script type="text/Javascript">
function SetValue()
{
window.opener.document.getElementById('txtInput').value
=document.getElementById('txtInput').value;
window.close();
}
function Unload()
{
window.opener.child=null;
}
</script>
<input type="text" id="txtInput" />
<input type="button" value="SetFather" onclick="SetValue()" />
</body>

JavaScript技術(shù)Javascript 兩個(gè)窗體之間傳值實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国语自产拍大学生在线观看 | 赤兔CHINESE最新男18GUY | 亚洲乱亚洲乱妇13p 亚洲乱色视频在线观看 | 国产欧美精品国产国产专区 | 久久精品国产只有精品 | 久久99热成人精品国产 | 国产精品系列在线一区 | 18 japanese宾馆直播 | 97免费视频在线观看 | 国产免费久久精品国产传媒 | 免费果冻传媒2021视频 | 久久精品在现线观看免费15 | 亚洲精品一卡二卡三卡四卡2021 | 国产激情一级毛片久久久 | 好硬好湿好大再深一点动态图 | GOGOGO高清在线播放韩国 | www.久艹| 精品国产乱码久久久久久软件 | 三级网站视频 | 日本理论片午午伦夜理片2021 | 手机观看毛片 | 亚洲zooz人禽交xxxx | 亚洲精品偷拍影视在线观看 | 精品国产在天天线在线麻豆 | 日本xxx在线观看免费播放 | 中文字幕乱码一区AV久久 | 持田香织abc | 国产专区青青在线视频 | 香蕉eeww99国产精选播放 | 国产99九九久久无码熟妇 | 131美女爱做视频午夜剧场 | 成人毛片免费播放 | 中文字幕人成乱码中国 | 动漫人物差差差30分钟免费看 | 91嫩草私人成人亚洲影院 | 女人的选择hd | 亚洲三区视频 | 人人做人人干 | 狠狠狠色丁香婷婷综合久久 | 国产人妻精品久久久久久很牛 | 窝窝影院午夜看片毛片 |