需求:因为项目只能用极速模式(webkit)访问,所以在用户使用非极速模式访问时,页面空白无反馈。
解决:检测用户当前浏览器内核,若非webkit内核则弹出提示并自动下载谷歌浏览器。
效果:
创建getVendorPrefix.js文件如下:
function getVendorPrefix() {
const body = document.body || document.documentElement
const style = body.style
const vendor = ['webkit', 'khtml', 'moz', 'ms', 'o']
let i = 0
while (i < vendor.length) {
// 此处进行判断是否有对应的内核前缀
if (typeof style[vendor[i] + 'Transition'] === 'string') {
return vendor[i]
}
i++
}
}
if (getVendorPrefix() !==