Kros的博客 Kros的博客
首页
  • CSS
  • 工具
  • Vue
  • js
  • Vue3
  • 算法
  • 折腾笔记
一言
  • 分类
  • 标签
  • 归档
码云

Kros

凡心所向,素履以往,生如逆旅,一苇以航
首页
  • CSS
  • 工具
  • Vue
  • js
  • Vue3
  • 算法
  • 折腾笔记
一言
  • 分类
  • 标签
  • 归档
码云
  • CSS

  • JavaScript

    • 兼容ie7的水平无限滚动
    • 节流防抖
    • 数组乱序
    • 开启全屏
    • 数据类型
    • 变量提升
    • this调用指向
    • 原型及原型扩展
    • js获取元素属性精度问题
    • setTimeout和setInterval
    • 数组判断
    • dom节点添加或插入元素
    • var、let和const的区别
    • 判断ellipsis是否省略生效
    • 使用ResizeObserver监听元素size变化
    • js自定义事件
    • use strict详解
    • 私有属性
    • js实现类的方式
    • call和apply的理解和使用
    • js失焦和点击事件顺序冲突
    • js中不常见但非常实用的运算符
    • for of和for in的区别
    • defer和async的区别
    • promise值穿透
    • js为什么会出现数字精确度丢失
    • js禁用F12开发者模式
    • 使用scrollTop和scrollTo滚动到目标位置
    • js实现打字机效果
    • 多种方式实现数组去重
    • 替换使用setTimeout
    • encodeURI和encodeURIComponent的区别
    • canvas实现弹跳小球
    • js实现跨标签页通信
    • 事件循环与微任务、宏任务
    • 浏览器存储数据方式
    • 常见的meta元数据使用
    • 使用InterSectionObserver判断元素区域(chatGPT)
  • 工具

  • Vue

  • antdv踩坑记录

  • Vue3

  • 前端
  • JavaScript
kros
2021-02-24

开启全屏

document.addEventListener('keydown', function(e) {
	if(e.keyCode == 81) {
		//针对不同浏览器添加对应前缀,fullscreen的写法为全小写,firefox特殊为fullScreen大写s
		if(!(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement)) {
		<!-- 开启 -->
			//不能使用方法赋值再调用,需要直接调用
			//let fullMethod = document.documentElement.requestFullscreen || document.documentElement.mozRequestFullScreen || document.documentElement.webkitRequestFullscreen;
			//fullMethod && fullMethod();
			if(document.documentElement.requestFullscreen) document.documentElement.requestFullscreen();
			else if(document.documentElement.mozRequestFullScreen) document.documentElement.mozRequestFullScreen();
			else if(document.documentElement.webkitRequestFullscreen) document.documentElement.webkitRequestFullscreen();
			
		}else {
			
		<!-- 关闭 -->
			//注意firefox的写法不同于其他浏览器
			if(document.exitFullscreen) document.exitFullscreen();
			else if(document.mozCancelFullScreen) document.mozCancelFullScreen();
			else if(document.webkitExitFullscreen) document.webkitExitFullscreen();
		}
	}
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
上次更新: 2025/09/05, 8:09:00
数组乱序
数据类型

← 数组乱序 数据类型→

最近更新
01
Find the next perfect square
09-05
02
Regex validate PIN code
09-05
03
Find the odd int
09-05
更多文章>
Theme by Vdoing | Copyright © 2020-2025 kros king
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
icon-heart-o icon-heart icon-infinity icon-pause icon-play link next prev