html自动定时弹窗,HTML 定时跳转网页

1:定时器

····

/*

setTimeout 设置过期时间

setTimeout(时间到了之后要执行的行为,什么时间 毫秒 开始执行)

setInterval 设置中断时间

setInterval(时间到了之后要执行的行为 , 间隔多长时间再执行 )

*/

// 两秒之后执行,执行完当前函数,不再重复执行

setTimeout(function(){

console.log("爆炸了");

} , 2000);

// 只是中断,每个一段时间休息一回,然后接着执行

setInterval(function(){

console.log("死了一回");

} , 2000 );

function daojishi(){

let t = new Date();

document.getElementById("showTime").innerHTML = t.toLocaleTimeString();

}

let fafuqushi = setInterval( daojishi , 1000 );

function stop(){

clearInterval(fafuqushi);

}

你敢按吗?

····

2:一闪一闪亮晶晶

····

html>

#container{

width: 400px;

height: 400px;

border: 1px solid yellowgreen;

background-color: black;

position: relative;

}

span{

font-size: 30px;

color: yellow;

position: absolute;

}

var timer;

function start_flash(){

timer = setInterval(function(){

document.getElementById("container").innerHTML = " * ";

let x = parseInt( Math.random()*400 + 1 );

let y = parseInt( Math.random()*400 + 1 );

document.getElementById("container").firstElementChild.style.left = x + "px";

document.getElementById("container").firstElementChild.style.top = y + "px";

} , 200 );

}

function stop_flash(){

clearInterval(timer);

}

亮晶晶

停止亮晶晶

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值