標籤:周杰倫 cti val tco var new 傳回值 定時 stc
<html> <head> <title>day02_js</title> <script type="text/javascript" language="javascript" src="js/test1.js"></script> </head> <body> <form> <h2>1.BOM示範針對window</h2> <input type="button" onclick="testConfirm()" value="confirm測試"/><br/><br/> <input type="button" onclick="testPromp()" value="promp測試"/><br/><br/> <input type="button" onclick="openTest()" value="open測試"/><br/><br/> <input type="button" onclick="closeTest()" value="close測試"/><br/><br/> <input type="button" onclick="refreshTest()" value="refresh測試"/><br/><br/> <input/><br/><br/> <input type="button" onclick="naviTest()" value="控制台查看資訊測試"/><br/><br/> <input type="button" onclick="TimeTest()" value="計時開始"/> <input type="button" onclick="clearTime()" value="計時結束"/> <input id="i1"/><br/><br/> </form> </body></html>
function testConfirm(){ var f = window.confirm("你確定此操作嗎?"); //確定加取消的彈出框 參數自訂,傳回值為點擊確定=true,點擊取消=false; alert(f); //列印返回的boolean值}function testPromp(){ var f = window.prompt("請輸入使用者名稱","周杰倫"); //提示加text加確定加取消彈出框 第一個參數提示,第二個參數預設值 alert(f); //列印輸入框中的值 點即取消則返回null}function openTest(){ //window.open("http://www.baidu.com");//開啟一個新頁面 var config = "toolbar=yes,width=500,height=300"; //toolbar顯示工具列 window.open("http://www.baidu.com","1",config) // 參數1為自訂,否則不能按照config的大小開啟新的視窗}function closeTest(){ window.close(); //關閉當前頁面}function refreshTest(){ window.location.reload(); //頁面重新整理}function naviTest(){ var arr = new Array(5); console.dir(arr); //console.dir()可以在控制台顯示一個對象所有的屬性和方法。 //console.log(window.navigator.appVersion); //會在瀏覽器控制台列印出資訊。 查看當前瀏覽的版本 //console.dir(window.navigator.appVersion);}var timer; //window定時器function TimeTest(){ timer = window.setInterval(‘func()‘,100);}var count = 0;function func(){ count++; document.getElementById("i1").value= count;}function clearTime(){ window.clearInterval(timer);}
JAVAscript學習筆記 jsBOM 第七節 (原創) 參考js使用表