admin管理员组文章数量:1130349
需求:因为项目只能用极速模式(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() !== 'webkit') {
window.location.href = 'https://dl-sh-ctc-2.pchome/31/dt/78.0.3904.70_chrome_installer32.zip?key=93cb618a96554ba17929b4503f2427ec&tmp=1573693848210'
alert('检测到您的浏览器无法正常访问系统,请将浏览器切换到 极速内核/极速模式!(点击地址栏最右侧的浏览器图标切换),强烈建议使用 谷歌Chrome浏览器 (已为您转至快速下载地址)!')
}
需求:因为项目只能用极速模式(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() !== 'webkit') {
window.location.href = 'https://dl-sh-ctc-2.pchome/31/dt/78.0.3904.70_chrome_installer32.zip?key=93cb618a96554ba17929b4503f2427ec&tmp=1573693848210'
alert('检测到您的浏览器无法正常访问系统,请将浏览器切换到 极速内核/极速模式!(点击地址栏最右侧的浏览器图标切换),强烈建议使用 谷歌Chrome浏览器 (已为您转至快速下载地址)!')
}
本文标签: 浏览器内核提示javascriptchrome
版权声明:本文标题:JavaScript 检测当前浏览器内核并提示下载谷歌Chrome浏览器 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1754065580a2638785.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论