第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

js,為什么這個(gè)postMessage無(wú)法向另一個(gè)網(wǎng)頁(yè)發(fā)送信息

js,為什么這個(gè)postMessage無(wú)法向另一個(gè)網(wǎng)頁(yè)發(fā)送信息

newsudhc3634140 2016-11-04 21:12:55
程序目標(biāo):點(diǎn)擊“打開(kāi)副本網(wǎng)頁(yè)”按鈕,然后點(diǎn)擊“發(fā)送信息”向打開(kāi)的網(wǎng)頁(yè)發(fā)送信息,新開(kāi)的網(wǎng)頁(yè)監(jiān)聽(tīng)并輸出接收的信息。兩個(gè)頁(yè)面在同個(gè)文件夾下網(wǎng)頁(yè)1<!DOCTYPE?html> <html> <head> ????<meta?charset="utf-8"> ????<title>主頁(yè)</title> </head> <body> ????<button?class="open-copy">打開(kāi)副本網(wǎng)頁(yè)</button> ????<button?class="send-msg">發(fā)送信息</button> ????<script?type="text/javascript"> ????????var?openCopy?=?document.getElementsByClassName("open-copy")[0]; ????????var?sendMsg?=?document.getElementsByClassName("send-msg")[0]; ????????openCopy.onclick?=?function(){ ????????????newPage?=?window.open("practice2.html"); ????????}; ????????sendMsg.onclick?=?function(){ ????????????newPage.postMessage("nihao","practice2.html"); ????????} ????</script> </body> </html>網(wǎng)頁(yè)2<!DOCTYPE?html> <html> <head> ????<meta?charset="utf-8"> ????<title>副本</title> </head> <body> ????<button?class="get-msg">接收打印信息</button> ????<script?type="text/javascript"> ????????var?getMsg?=?document.getElementsByClassName("get-msg")[0]; ????????window.addEventListener("message",function(e){ ????????????newMsg?=?document.write(e.data); ????????????getMsg.onclick?=?function(){ ????????????????console.log(e.data); ????????????} ????????},false); ????</script> </body> </html>
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 2755 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)