JavaScript父子視窗互傳資料__Java

來源:互聯網
上載者:User
<html><head><title>JS父子視窗</title><script>function alterImg(){var _uname=document.frm.uname.value;//擷取表單中控制項的值var res   =showModalDialog("JS強制回應對話方塊.html",_uname,"dialogwidth:300;dialogheight:300;");/*JS強制回應對話方塊.html--強制回應對話方塊開啟的頁面_uname--傳遞給子表單xxx.html的參數,它是一個字串類型propert:對話方塊的屬性設定,如對話方塊寬度,滾動等res--強制回應對話方塊的傳回值,即子表單傳遞給父表單的資料*/if(res!=null) {document.getElementById("image").src=res; //變數不能加引號,注意哪些加引號,哪些不加引號}else {document.getElementById("image").src="head/b1.bmp";}}</script></head><body><center><form name="frm"><table cellspacing="1px" width="400px" border="1px"><caption>表格標題</caption><tr><th colspan="2">使用者註冊</th></tr>  <tr><td>使用者名稱</td><td><input type="text" value="" name="uname"></td></tr><tr><td>頭像</td><td><img id="image" src="head/b1.bmp"> <a href="javaScript:alterImg();">換一張</a></td></tr></table></form></center></body></html>

<html><head><title>JS強制回應對話方塊</title></head><script>function init() {//擷取使用者名稱文字框的值//在對話方塊頁面中window.dialogArguments屬性工作表示父表單傳遞過來的參數document.getElementById("sp").innerText=window.dialogArguments;//給span層添加普通文本}function sel(a) {//a指圖片對象a.border="2px";}function unsel(a) {a.border="0px";}function ok(a) {//window.returnValue屬性工作表示子表單準備返回給父表單的傳回值,在子表單關閉後返回window.returnValue=a.src;//window可以去掉window.close();}</script><body onload="init();">    <center>    <span id="sp"></span>頭像    <table>    <tr>    <td>    <script>    for(var i=1;i<21;i++) {    document.write("<img src=head/b"+i+".bmp onmouseover=se1(this) onmouseout=unse1(this) onclick=ok(this)>");    if(i%5==0) {    document.write("<br>");    }    }    </script>    </td>    </tr>    </table>    </center></body></html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.