window身上的方法
内置函數
alert()
parseInt()
parseFloat()
setInterval();
setTimeout();
clearTimeout();
clearInterval();
。。。。。。。。。。
資訊框
alert("123123132");
對話框:确定拿到輸入的資訊,取消拿到null
var a = prompt("請輸入要充值的金額");
console.log(a)
選擇框
var a = confirm("會彈出一個什麼呢")
console.log(a)
demo:
function fn(){
var a = confirm("你沖錢麼?") //相當于一個布爾值選擇器
if(a){
prompt("尊貴的使用者,請輸入你充值的金額")
}else{
fn();
}
}
fn()
window方法打開和關閉
var obtn = document.getElementById("btn");
var obtn2 = document.getElementById("btn2");
obtn.onclick = function(){
// open("http://www.baidu.com","_blank","width=300,height=300,left=200,top=200");
open("./6計時器.html","_blank","width=300,height=300,left=200,top=200");
}
obtn2.onclick = function(){
close(); //關閉自己本身
}
// 非腳本打開的頁面