javascript - How to turn off the js effect of newly opened windows in js
漂亮男人
漂亮男人 2017-05-18 10:57:11
0
4
598

I made a window shaking effect, but the newly opened window has a shaking effect, but how to clear the effect, and how to close it after clearing the effect, I don’t know how to write...

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>窗口抖动</title>
</head>
<body>
<script>
    var w=window.open('','', 'width=100,height=100');
    w.resizeTo(300,300);
    var loop;
    var timer;
    var offX;
    var offY;
    var status = 1;
    timer = setInterval(function(){
        w.moveTo(100,100);
        if(loop<10){
            clearInterval(timer);
        }
        status = Math.random()*10 > 5 ? 1 : -1;
        offX = Math.random()*20*status;
        offY = Math.random()*20*status*-1;
        w.moveBy(offX,offY);
        loop++;
    },10);
</script>
</body>
</html>
漂亮男人
漂亮男人

reply all(4)
phpcn_u1582
var w=window.open('','', 'width=100,height=100');
w.resizeTo(300,300);
var loop = 0;  // 设置默认值
var timer;
var offX;
var offY;
var status = 1;
timer = setInterval(function(){
    w.moveTo(100,100);
    // 设为大于
    if(loop > 10){
        clearInterval(timer);
    }
    status = Math.random()*10 > 5 ? 1 : -1;
    offX = Math.random()*20*status;
    offY = Math.random()*20*status*-1;
    w.moveBy(offX,offY);
    loop++;
},10);
w.close() // 关闭窗口
小葫芦
setTimeout(function () {
  clearInterval(timer);
},1000);
setTimeout(function () {
  w.close();
},2000)
黄舟
if(loop>10){
      clearInterval(timer);
}

The loop should be greater than 10. You wrote it wrong. Also give an initial value of zero when declaring the loop.

左手右手慢动作

Clear the timer and then execute a method to close the window

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template