使用介绍:显示“确定”、“取消”对话框,如果按了“确定”,就返回值true,否则就返回false。
if(confirm("是否继续?")){
{alert("确定");}
else
{alert("取消");}
}
具体使用如下:
<head>
<title></title>
<script type ="text/javascript" >
function confi(){
if(confirm("是否进入?"))
{alert ("进来了");}
else
{alert ("出来了");}
}
</script>
</head>
<body>
<input type ="button" value ="确定" onclick ="confi()" />
</body>
在弹出对话框中选择确认后,进入另一个对话框。。
知识点2:navigate的使用方法:<input type ="button" value ="确定2" onclick ="navigate ('htmlpage2.htm')" />
注释:点击确定2按钮进入htmlpage2.htm页面,相当于连接的意思。
知识点3:setInterval ,每隔几秒执行一个操作;如果要停止用clearInterval。
先定义:var starId;
function star(){
starId =setInterval("alert('你好!');",1000);
}
然后:<input type ="button" value ="一直弹" onclick ="star()" />
<input type ="button" value ="停止" onclick ="clearInterval(starId)" />
结果:在点击“确定3”后几秒后就会出现“你好!”,过几秒又会弹出来“你好!”;当点击“停止”的时候就会停止的。
知识点4:setTimeout是定时执行一个内容,但是只执行一次;取消用clearTimeout。
语法:var timeoutid=setTimeout("alert('hello')",2000);