码迷,mamicode.com
首页 > Web开发 > 详细

js-7-15

时间:2015-07-16 00:22:18      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

//页面跳转

<h1>第一页</h1>
<a href="page2.html">跳转第二页</a>
<input id="btn" type="button" value="前进"/>
<script type="text/javascript">
    var btn = document.getElementById("btn");
    btn.onclick = function() {
        window.history.go(-1);
    }
</script>

//相对移动,针对IE
//    window.moveBy(100,100);
//    window.moveTo(100, 100);
//    window.resizeBy(300, 300);
//    window.resizeTo(300, 300);

 //浏览器离左边屏幕和上边屏幕的距离
//    alert(window.screenLeft);
//    alert(window.screenTop);
//    alert(document.body.offsetWidth);
//    alert(document.body.offsetHeight);
//    alert(window.screenX);
//    alert(window.screenY);

//计时

var btn = document.getElementById("btn");
        var btn2 = document.getElementById("btn2");
        var txt = document.getElementById("txt1");
        var r;
        btn.onclick = function() {
            function test() {
                var day = new Date();
                txt.value = day;
                r = window.setTimeout(test, 1000);
            }
            test();
        };

        btn2.onclick = function () {
            window.clearTimeout(r);
        };

//锚点操作

<a name="a" href="#">锚点1</a>
    <a name="a" href="#">锚点2</a>
    <a href="#">锚点3</a>
    <div></div>
    <script type="text/javascript">
        alert(document.anchors[0].innerHTML);
    </script>
    <a href="#a">回到顶部</a>

js-7-15

标签:

原文地址:http://www.cnblogs.com/yocia/p/4649733.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!