<script>
function testLocation(){
var href = window.location.href;
var hostname = window.location.hostname;
var port = window.location.port;
var host = window.location.host;
alert(href+"---------"+hostname+"-----------"+port"-----"+host);
}
//修改当前的URL地址
// window.location.href = "http://www.baidu.com";
//重新加载页面 类似于刷新页面
// window.location.reload();
function testHistory(){
//返回浏览器历史李彪中的URL数量
// var len = window.history.length;
// alert(le);
//前进操作
// window.history.foorward();
//后退操作
//window.history.back();
//控制前进和后退的网页 如果是正数代表前进,负数代表后退
window.history.go(1);
}
function testScreen(){
//获得当前屏幕的分辨率
var he = window.screen.height;
var wi = window.screen.width;
alert(he+"---"+wi);
}
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
/***********三种弹框*********************/
function demo1(){
window.alert("弹窗1");
}
function demo2(){
//含有确认取消的弹框
var flag = window.confirm("是否删除");
alert(flag);
}
function demo3(){
//可以输入内容的弹窗
var flag2 = window.prompt("请输入内容","例如:我叫侯慧慧");
alert(flag2);
}
/*************定时器*******************/
function getTime(){
var date = new Date();
//获得时间
var time = date.toLocaleDateString();
//获得id名称是span_1的对象
var span = document.getElementById("span_1");
span.innerHTML = time;
}
//1s之后进行方法的调用 调用一次
// window.setTimeout("getTime()",1000);
//每间隔1s就会进行方法的调用 调用多次
var in1 = window.setInterval("getime",1000);
function demo4(){
//清除定时器
window.claerInterval(in1);
}
</script >
</head>
<body onload ="getDate()">
<p>
<input type = "button" value = "点击" onclick = "demo1()"/>
</p>
<p>
<input type = "button" value = "点击弹框2" onclick = "demo2()"/>
</p>
<p>
<input type = "button" value = "点击3" onclick = "demo3()"/>
</p>
定时器:<span id ="span_1"></span>
<p>
<input type = "button" value = "清除定时器" onclick = "demo4()"/>
</p>
</body>
</html>