首页 > Windows开发 > 详细

插件写法之脚本运行环境,mac和window检测

时间:2019-02-10 20:57:51      阅读:227      评论:0      收藏:0      [点我收藏+]
(function(root, factroy){
 
/*
* 在这里进行对脚本运行环境的检测判断
* 浏览器中 有window对象
* node.js服务器端 有Global对象
*/
if(root === undefined){
console.log("请注意,这是Node.js运行环境")
}else{
console.log("请注意,这是浏览器运行环境")
}

 

// 下在是判断mac和widow的方法
let isSystem= function(){
/** * 是否为mac系统 * */
let isMac = function() {
return ‘mac系统‘+/macintosh|mac os x/i.test(navigator.userAgent);
}();
/** * 是否为windows系统 * */
let isWindows = function() {
return ‘window‘+/windows|win32/i.test(navigator.userAgent);
}();
console.log("是否MAC系统"+isMac," , "+"是否window系统"+isWindows)
return ‘isSys‘;
}();
// isSystem();
console.log(isSystem)
 
})(this,function(){
  下面是自己的工具代码
})

插件写法之脚本运行环境,mac和window检测

原文:https://www.cnblogs.com/andy-lehhaxm/p/10360163.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!