您的位置:首页 > Web前端 > JavaScript

js笔记5浏览器对象和history和screen

2016-07-17 18:03 591 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body onload="myWin()">
<button id="btn" onclick="stopWin()">按钮</button>
<p id="pid">test</p>
<script>

//    document.write("宽度为:"+window.innerWidth+"高度为:"+window.innerHeight);
//    function btnClick() {
//    window.open("baidulogin.html","windowname","height=200,width=200,top=100,left=100,toolbar=no,menubar=no");
//        window.close();
//    }
//延时执行
//    var myTime = setInterval(function () {
//        getTime()
//    }, 1000);
//    function getTime() {
//        var d = new Date();
//        var t = d.toLocaleTimeString();
//        document.getElementById("pid").innerHTML = t;
//    }
//
//    function stopTime(){
//        clearInterval(myTime);
//    }

//自己执行,自己调用自己
var win;
function myWin() {
alert("hello")
win = setTimeout(function () {
myWin()
}, 3000);
}

function stopWin(){
clearTimeout(win);
}

</script>

</body>
</html>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>ceshi</title></head><body><!--<button id="btn" onclick="goceshi()">按钮</button>--><!--<script>--><!--function goceshi(){--><!--history.back();--><!--}--><!--</script>--><form><input type="text" id="username"><button id="btn" onclick="save()">按钮</button><script>function save(){var name=document.getElementById("username").value;if(name=="hello"){history.go(-1);}else{alert("输入错误")}}</script></form></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title></title></head><body><a href="js_717_history.html">跳转到js_717</a><!--<button id="btn" onclick="gojs()">按钮</button>--><!--<script>--><!--//1.history对象--><!--// window.history对象包含浏览器的历史url集合--><!--//2.history方法--><!--//history.back();与在浏览器点击后退按钮相同--><!--//history.forward()与在浏览器中点击前进相同--><!--//history.go()进入某个历史界面--><!--function gojs() {--><!--history.forward();--><!--}--><!--</script>--><p id="pid"></p><button id="btn" onclick="getLoc()">按钮</button><script>function getLoc() {//        location.assign("https://www.baidu.com");document.getElementById("pid").innerHTML = window.location.pathname;}document.write("可用高度"+screen.availHeight+"可用宽度"+screen.availWidth);document.write("高度"+screen.height+"宽度"+screen.width);</script></body></html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: