如果用户在第一次访问时不点击"允许被阻止的内容",我的网站在Internet Explorer中无法正常工作。 我想到了一些JavaScript代码,可以检测所打开页面的浏览器,并弹出窗口显示:“您正在使用Internet Explorer,请在重新加载页面时点击页面底部的“允许被阻止的内容”以允许运行脚本和ActiveX控件,否则网站可能无法正常工作。” 但它本身也是脚本,所以只有在用户点击它后才能看到它。现在它是无用的,因为它告诉用户只有在允许后才能点击该按钮。
我的JS代码如下:
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isFirefox = typeof InstallTrigger !== 'undefined';
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
var isChrome = !!window.chrome && !isOpera;
var isIE = /*@cc_on!@*/false || !!document.documentMode;
if(isChrome === false && isSafari === false && isFirefox === false && isOpera === false)
{alert('You are in Internet Explorer. Please allow running scripts and ActiveX controls by clicking "Allow Blocked Content" at the bottom of the page upon reload. Otherwise the site may not work correctly.'
);};
我需要一种不使用 JS 或 JQuery 的方法来检测浏览器并显示消息。有人有想法吗?