js写网页闪屏震动

来源:互联网 发布:淘宝邮箱格式怎么写的 编辑:程序博客网 时间:2024/06/05 05:44
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
    *
    {
        font-size:12px;
        font-family:@楷体,Arial;
        font-weight:normal;
        color:#333;
        }/*规定了所有的字体样式*/
        textarea
        {
            width:100%;
            height:98%;
            border:1px solid black;
            }/*定义了多行文本的样式*/
    </style>
    <script type="text/javascript">
        function resizeWindow() {
            var windowWidth = 240, windowHeight = 180;
            window.moveTo((screen.availHeight - windowHeight) / 2);
            window.resizeTo(windowWidth, windowHeight);
        }
        function shakeWin(stepId) {
            var stepId;
            if (!stepId) stepId = 0;
            switch (stepId) {
                case 0:
                    window.moveBy(-5, -5);
                    break;
                case 1:
                    window.moveBy(10, 0);
                    break;
                case 2:
                    window.moveBy(-10, -10);
                    break;
                case 3:
                    window.moveBy(10, 0);
                    break;
                case 4:
                    window.moveBy(-5, -5);
                    break;
                default:
                    return;
            }
            stepId++;
            setTimeout("shakeWin(" + stepId + ");", 20);
        }
        function $(str) {
            document.getElementById(str);
        }
        window.onload = resizeWindow;
    </script>
</head>
<body style="overflow:auto">
<input type="button" value="点击查看震动闪屏效果" onclick="shakeWin();" />
</body>
</html>
原创粉丝点击