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(); //关闭自己本身 } // 非脚本打开的页面