js问题之判断是否是火狐、IE浏览器

一、

在vue项目中试过,IE浏览器版本是IE11
	// js文件--methods 新增一方法
	,myBrowser () {
		let userAgent = navigator.userAgent
		if (userAgent.indexOf("Firefox") > -1) {
			return "FF"
		}
		if (!!window.ActiveXObject || "ActiveXObject" in window || window.navigator.userAgent.indexOf("MSIE") >= 1) {
			return "IE"
		}
	}
	// 调用
	const browser = this.myBrowser()
	if (browser == "IE"){
		// code...
	}else if (browser == "FF") {
		// code..
	}

猜你喜欢

转载自blog.csdn.net/yan263364/article/details/85099109