5秒后跳转指定页面网址案例分析教程

[复制链接]
查看1737 | 回复0 | 2020-6-6 10:07 | 显示全部楼层 |阅读模式
5秒后跳转指定页面网址案例分析教程JavaScript语法代码:
  1. var timer = 5;
  2. var btn = document.querySelector('button');
  3. setInterval(zidiu, 1000);
  4. function zidiu() {
  5.     if (timer == 0) {
  6.         location.href = 'http://www.zidiu.com';
  7.     } else {
  8.         btn.innerHTML = '还剩下' + timer;
  9.         timer--;
  10.     }
  11. }
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-4-16