当前位置: 首页 > news >正文

防考试作弊切屏

防考试作弊切屏

方法一:监听页面失焦聚焦事件:防止任何操作

  • 监听考试页面失焦事件记录切出时间
  • 页面聚焦时累积记录切入时间,累积时间大于1分钟自动交卷并移除时间
  • 页面销毁移出事件
  • ***bug:必须把事件回调定义为方法,在销毁的时候才可以销毁
 mounted() {window.addEventListener('blur', this.blurDom);window.addEventListener('focus', this.focusDom);},destroyed() {console.log(1111111, '页面销毁')window.removeEventListener('blur', this.blurDom)window.removeEventListener('focus', this.focusDom)},methods: {blurDom() {this.start = Date.now()console.log(1111111, '失去焦点', this.start)},focusDom() {if (this.start == 0) returnthis.end = Date.now()this.hideTime += this.end - this.startconsole.log(1111111, '页面聚焦', this.end, this.hideTime)if (this.hideTime > 1 * 60 * 1000) {console.log('没机会了')this.hilarity(1)window.removeEventListener('blur', this.blurDom)window.removeEventListener('focus', this.focusDom)} else {this.$message.warning('切屏时间超过' + this.setTime + '分钟自动交卷');}},}

方法二:监听页面显示隐藏方法:只能监听页面被全部覆盖的情况,小窗口监听不到

  • 监听考试页面隐藏记录切出时间
  • 页面显示时累积记录切入时间,累积时间大于1分钟自动交卷并移除时间
  • 页面销毁移出事件
  • ***bug:必须把事件回调定义为方法,在销毁的时候才可以销毁
 mounted() {document.addEventListener("visibilitychange", this.watchDom);},destroyed() {console.log(1111111, '页面销毁')document.removeEventListener("visibilitychange", this.watchDom) },methods: {watchDom() {if (document.visibilityState == 'hidden') {this.start = Date.now()console.log(1111111, 'start', this.start, this.hideTime)} else {this.end = Date.now()this.hideTime += this.end - this.startconsole.log(1111111, 'end', this.end, this.end - this.start, this.hideTime)if (this.hideTime > 1 * 60 * 1000) {this.hilarity(1)document.removeEventListener("visibilitychange", this.watchDom) } else {this.$message.warning('切屏时间超过' + this.setTime + '分钟将自动交卷');}}},}
http://www.lryc.cn/news/308737.html

相关文章:

  • 浅析能耗监测系统在大型数据中心的应用
  • robotframework-去除字符串左侧的0的方法
  • 【Linux C | 网络编程】getaddrinfo 函数详解及C语言例子
  • 深度学习主流开源框架:Caffe、TensorFlow、Pytorch、Theano、Keras、MXNet、Chainer
  • [Linux] vim及gdb的使用
  • Android WebView访问网页+自动播放视频+自动全屏+切换横屏
  • php PhpSpreadsheet 读取日期变数字问题解决
  • 前端架构: 脚手架包管理工具之lerna的全流程开发教程
  • [安洵杯 2019]easy_serialize_php1
  • 【前端素材】推荐优质在线通用果蔬商城电商网页eStore平台模板(附源码)
  • 开源软件的商业模式探析:开放与盈利的平衡
  • 使用全局事件总线实现任意组件间的通讯
  • 文件基础和文件fd
  • 3dgs学习(二)—— 3d高斯与协方差矩阵及其几何意义
  • ZStack Cube超融合入选IDC《中国超融合基础架构市场评估》报告
  • 每日一题——LeetCode1556.千位分隔符
  • 8.网络游戏逆向分析与漏洞攻防-游戏网络架构逆向分析-游戏底层功能对接类GameProc的实现
  • Redis冲冲冲——事务支持,AOF和RDB持久化
  • 路由菜单路径匹配方法
  • 设计模式浅析(九) ·模板方法模式
  • 无用工作、UBI与AI
  • 【监控】grafana图表使用快速上手
  • Django常用命令
  • 【center-loss 中心损失函数】 原理及程序解释(更新中)
  • 什么是 HTTPS 证书?作用是什么?
  • 为什么软考报名人数越来越多?
  • 【投稿优惠|快速见刊】2024年图像,机器学习和人工智能国际会议(ICIMLAI 2024)
  • html2canvas 将DOM节点转成图片
  • 【多线程】常见锁策略详解(面试常考题型)
  • Python列表操作函数