【发布时间】:2015-06-08 10:31:08
【问题描述】:
我当前的网页只能在谷歌浏览器中正确显示。因此,我想让谷歌浏览器以外的浏览器显示“请使用谷歌浏览器”的弹出窗口。
目前我正在使用
alert("请使用谷歌浏览器");
但这里的问题是它还会在 google chrome 中显示该警报。有没有办法仅在特定浏览器中显示此警报?
【问题讨论】:
标签: html google-chrome cross-browser dreamweaver
我当前的网页只能在谷歌浏览器中正确显示。因此,我想让谷歌浏览器以外的浏览器显示“请使用谷歌浏览器”的弹出窗口。
目前我正在使用
alert("请使用谷歌浏览器");
但这里的问题是它还会在 google chrome 中显示该警报。有没有办法仅在特定浏览器中显示此警报?
【问题讨论】:
标签: html google-chrome cross-browser dreamweaver
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")}
【讨论】: