JavaScript中的Window

來源:互聯網
上載者:User

標籤:col   htm   button   div   port   cat   函數   head   input   

<!DOCTYPE html><html>    <head>        <meta charset="utf-8" />        <meta name="viewport" content="width=device-width, initial-scale=1">        <title>JavaScript中的Window</title>        <!--Window學習        1.Window常用的方法          對話方塊            alert---彈出警告框(彈出的視窗只能點確定)            confirm----確認框(彈出的視窗既可以點確定,也可以點取消),點確定會返回true,點取消會返回false            prompt---prompt("描述內容"):彈出一個輸入框,並可以擷取輸入結果        延時函數            setTimeout("執行動作",毫秒數)----延誤指定的毫秒數,然後執行指定的動作,執行動作可以是另外的方法,也可以是匿名的方法,注意必須加引號            clearTimeOut---清除指定的延時函數                setInterval("執行動作",毫秒數)---每隔多少秒都會執行一次這個函數                                子視窗          window.open("open.html","win","width=100,heigth=200")          window.close();關閉視窗        2.location                3.history                                        -->        <script type="text/javascript">            var ids;            function testAlert(){                alert("測試alert");            }            function testConfirm(){                var testC=confirm("測試confirm");                alert(testC);//點確定會返回true,點取消會返回false,            }            function testPrompt(){                var tetsp=prompt("請輸入一個值");                alert(tetsp);            }            function testTimeout1(){                setTimeout("alert(‘直接使用alert‘)",2000);            }            function testTimeout(){                setTimeout("testTimeoutFunction()",3000);//調用另外的方法            }            function testTimeoutFunction(){                alert("掉用方法");            }            function testTimeout2(){                ids=setTimeout(function(){                    alert("匿名方法");                    },1000);            }            function testClearTimeOut(){                clearTimeout(ids);            }                        function testSetInterval(){                setInterval(function(){                    alert("延時函數");                },1000);            }                function testWindow(){                 window.open("son.html","win","width=20,heigth=10,top=100,left=100");            }                                </script>    </head>    <body>     <input type="button" value="測試alert" onclick="testAlert()" />         <input type="button" value="測試confirm" onclick="testConfirm()" />     <input type="button" value="測試prompt" onclick="testPrompt()" />     <hr />     <input type="button" value="測試setTimeout1" onclick="testTimeout1()" />     <input type="button" value="測試setTimeout" onclick="testTimeout()" />     <input type="button" value="測試setTimeout2" onclick="testTimeout2()" />     <hr />     <input type="button" value="測試ClearTimeOut" onclick="testClearTimeOut()" />     <hr />     <input type="button" value="測試setInterval" onclick="testSetInterval()" />     <hr />     <input type="button" value="測試子視窗" onclick="testWindow()" />         </body></html>

另外再設定一個子視窗測試window.close()

子視窗的代碼:

<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1"><title>子視窗</title><!-- window.close();關閉視窗 --><script type="text/javascript">function testClose(){window.close();}</script></head><body>這是一個子視窗<input type="button" value="測試window.close" onclick="testClose()"/></body></html>

  

JavaScript中的Window

聯繫我們

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