<!DOCTYPE html>
<!--
??三种消息框:
??????1.提示框prompt
??????2.警告框alert
??????3.确认框comfirm("文本","默认值")
???计时:setTimeout("js代码",毫秒) clearTimeout()
-->
<html lang="en">
<head>
???<meta charset="UTF-8">
???<title>js-window</title>
???<style type="text/css">
???????a {
???????????color: #ff1d1f;
???????????text-decoration: underline;
???????}
???</style>
</head>
<body onload="startTime()">
<p id="p1">
<p>
???<a href="http://www.baidu.com">百度</a><br/>
???<a href="http://www.bilibili.com">哔哩哔哩动画</a><br/>
???<input type="button" value="点击我返回上一个页面" onclick="past()"><br/>
???<input type="button" value="点击我去下一个页面 " onclick="next()"><br/>
???<script>
???????var a = document.getElementById("p1");
???????a.innerHTML = "高:" + window.innerHeight + " ??宽:" + innerWidth + " ?可用高度:" + window.screen.availHeight + " ?可用宽度:" + window.screen.availWidth;
???????//window.open(url="http://www.baidu.com",target="_blank");
???????//window.close();
???????// window.resizeTo(100,100);ie才有用
???????// window.moveTo(500,500);ie才有用
???????document.writeln("url:" + window.location.href + "<br/>");
???????document.writeln("路径:" + window.location.pathname + "<br/>");
???????document.writeln("端口:" + window.location.port + "<br/>");
???????function past() {
???????????window.history.back();
???????}
???????function next() {
???????????window.history.forward();
???????}
???</script>
<input type="button" value="点击我出现警告框" onclick="test1()"><br/>
<input type="button" value="点击我出现确认框" onclick="test2()"><br/>
<input type="button" value="点击我出现提示框" onclick="test3()"><br/>
???<script>
???????function test1(){//警告框
???????????alert("这是一个警告框");
???????}
???????function test2(){//确认框
???????????var a=confirm("你是我的儿子吗?");
???????????if(a==true){
???????????????alert("乖儿子");
???????????}
???????????else{
???????????????alert("蠢儿子,连爸爸都不认识了");
???????????}
???????}
???????function test3(){//提示框
???????????var a=prompt("想一想你的爸爸是谁?","万涛");
???????????if(a=="万涛"){
???????????????alert("儿子乖,还记得爸爸");
???????????}
???????????else{
???????????????alert("这个蠢儿子,怎么连你爸爸都不认识了呢???");
???????????}
???????}
???</script>
<p id="p2"></p>
<script>//js计时
???function startTime(){
??????var date=new Date();
??????var h=date.getHours();
??????var m=date.getMinutes();
??????var s=date.getSeconds();
??????h=checkTime(h);
??????m=checkTime(m);
??????s=checkTime(s);
??????document.getElementById("p2").innerHTML="时间为:"+h+":"+m+":"+s;
??????var t=setTimeout("startTime()",500);
???}
???function checkTime(i){
???????if(i<10){
???????????i="0"+i;
???????}
???????return i;
???}
</script>
<input type="button" value="点击此按钮设置session(这个还不会,以后再看!!!)">
</body>
</html>
js3
原文地址:http://www.cnblogs.com/wantao/p/7966136.html