开启全屏
export function fullScreen(){
var el = document.documentElement,
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,
wscript;
if(typeof rfs != "undefined" && rfs) {
rfs.call(el);
return;
}
if(typeof window.ActiveXObject != "undefined") {
wscript = new ActiveXObject("WScript.Shell");
if(wscript) {
wscript.SendKeys("{F11}");
}
}
}
禁止键盘事情 Esc 和 F11 是禁不掉的
//禁止键盘事件
export function stopKeyDownThing(){
document.onkeydown = function(e) {
var evt = window.event || e;
var code = evt.keyCode || evt.which;
//屏蔽F1---F12
if (code > 111 && code < 124) {
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.keyCode = 0;
evt.returnValue = false;
}
}
if (code == 27) {
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.keyCode = 0;
evt.returnValue = false;
}
}
};
//禁止鼠标右键菜单
document.oncontextmenu = function(e) {
return false;
};
//阻止后退的所有动作,包括 键盘、鼠标手势等产生的后退动作。
history.pushState(null, null, window.location.href);
window.addEventListener("popstate", function() {
history.pushState(null, null, window.location.href);
});
}
获取当前浏览器
/ 获取当前登录的浏览器
export function getNowBrowser(){
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
// console.log("loginuserAgent:", userAgent)
//判断是否Opera浏览器
if (userAgent.indexOf("Opera") > -1) {
return "Opera"
};
//判断是否Edge浏览器
if (userAgent.indexOf("Edg") > -1){
return 'Edge'
}
//判断是否Firefox浏览器
if (userAgent.indexOf("Firefox") > -1) {
return "firefox";
}
//判断是否Chrome浏览器
if (userAgent.indexOf("Chrome") > -1){
return "Chrome";
}
//判断是否Safari浏览器
if (userAgent.indexOf("Safari") > -1) {
return "Safari";
}
//判断是否IE浏览器
if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
return "IE";
}
if ( userAgent.indexOf("Trident") > -1){
return "IE";
}
}
获取当前屏幕宽高
// 获取当前浏览器的屏幕宽高
export function getCurrentScreen(){
let width= window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
let height= window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
console.log(width,height,'宽高');
return {width:width,height:height}
}