最近想给自己的工具增加点击全屏功能,但是发现全屏后都黑了。 我是这么全屏的:
// 全屏 $(".main").on("click",()=>{ document.body.requestFullscreen(); });
但是发现元素都黑了,是因为全屏后背景自动黑了,所以啥也看不出来了,解决办法如下:
它在Firefox和Chrome上有效
css:
::backdrop { z-index:0; background-color: white !important; } html, *:fullscreen, *:-webkit-full-screen, *:-moz-full-screen { background-color: white !important; z-index:1; }
做了一个墨水屏用的番茄钟,想要显示电池状态,于是查询到以下资料。
API是navigator
对象提供的:
navigator.getBattery().then(function(result){}); 通过对
getBattery()
的调用,可以得到一个promise
,其返回一个then方法
,并提供一个BatteryManager
对象:
BatteryManagery { charging: false, chargingTime: Infinity, dischargingTime: 8940, level: 0.59, onchargingchange: null, onchargingtimechange: null, ondischargingtimechange: null, onlevelchange: null }