JavaScript特效執行個體008-關閉彈出的視窗時,重新整理父視窗

來源:互聯網
上載者:User

標籤:javascript

執行個體008                  關閉彈出的視窗時,重新整理父視窗執行個體說明關閉彈出的視窗時,同時重新整理父視窗,一般用來使父視窗擷取最新的資料。技術要點本執行個體主要應用window.open()語句開啟新視窗,並在新視窗中應用opener屬性,該屬性返回一個引用,用於指定開啟本視窗的視窗對象。文法:window.openerwindow.opener.方法window.opener.屬性功能:返回的是一個視窗對象。opener屬性與開啟該視窗的父視窗相聯絡,當訪問子視窗中opener屬性時,返回的是父視窗,通過該屬性,可以使用父視窗對象中的方法和屬性。reload()方法是用來重新整理指定視窗的。實現過程(1)要彈出的視窗,並且實現關閉重新整理父視窗的頁面new.html
<html><head><meta charset="utf-8" /><title>彈出的視窗</title><style type="text/css">body{background-image:url(new.jpg);background-repeat:no-repeat;}</style><script>function pp(){alert(window.opener);window.opener.location.reload();window.close();}</script></head><body><input type = "button" value = "關閉" onClick="pp();"/></body></html>
(2)主視窗index.html
<html><head>    <meta charset="utf-8" />    <script type="text/jscript" language="javascript">window.open("new.html","new","height=280,width=800,top=10,left=20,resizable=no, location=no",false);        </script>        <style type="text/css">        p{font-size:24px;color:#F00;}        </style>    </head>    <body>    <p>網站首頁</p>    </body></html>
註:style標籤的內容為css的知識,我們關注的是script標籤內的內容。這樣我們的這個執行個體就做好了。



JavaScript特效執行個體008-關閉彈出的視窗時,重新整理父視窗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.