【问题标题】:Display alert in all browsers other than google chrome在除 google chrome 之外的所有浏览器中显示警报
【发布时间】:2015-06-08 10:31:08
【问题描述】:

我当前的网页只能在谷歌浏览器中正确显示。因此,我想让谷歌浏览器以外的浏览器显示“请使用谷歌浏览器”的弹出窗口。

目前我正在使用

alert("请使用谷歌浏览器");

但这里的问题是它还会在 google chrome 中显示该警报。有没有办法仅在特定浏览器中显示此警报?

【问题讨论】:

    标签: html google-chrome cross-browser dreamweaver


    【解决方案1】:
    var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    

    这会检查浏览器是否是 chrome,所以现在你可以做什么:

    if (is_chrome != true) {alert("Please use Google Chrome")}
    

    或

    if (is_chrome != true) {prompt("Please use Google Chrome Download it here:", "https://www.google.com/chrome/browser/index.html")}
    

    【讨论】:

    猜你喜欢
    • 2019-01-01
    • 2013-09-17
    • 2015-02-01
    • 1970-01-01
    • 2016-11-20
    • 2012-09-09
    • 2022-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多