当用户使用Internet或Edge访问我的站点时,我试图发出警告,但我的代码没有显示任何内容。
IE/边缘检测器:
var isIE = /*@cc_on!@*/ false || !!document.documentMode,
isEdge = !isIE && !!window.StyleMedia;
if (isIE || isEdge) {
// Do stuff here
}My:
<body>
<!-- IE Alert -->
<div id="unsupported-browser" title="Browser Not Supported" style="display:none;text-align:center;">
<p>
Uh Oh! Your browser is not supported!
Downloading a newer browser is recommended for safety and security!
Download one of the following browsers for an optimal experience!
<a href="https://www.mozilla.org/en-US/firefox/new/" target="_blank">Mozilla Firefox</a>
<a href="https://www.google.com/chrome/index.html" target="_blank">Google Chrome</a>
</p>
</div>
</body>My JQuery (带有IE/边缘检测器):
$(document).ready(function () {
$('#unsupported-browser').dialog({
autoOpen: false,
width: 600,
buttons: {
"Ok": function () {
$(this).dialog("close");
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
// Detect Internet Explorer/Edge
var isIE = /*@cc_on!@*/ false || !!document.documentMode,
isEdge = !isIE && !!window.StyleMedia;
if (isIE || isEdge) {
$(function () {
$('#unsupported-browser').dialog('open');
return false;
});
}
});我相信问题就在对话框的某个地方,因为当我在检测器中使用alert();时,警报就会显示得很好。删除div样式中的display:none;也没有任何效果。
发布于 2018-11-19 22:15:36
对于遇到此问题的任何人,还必须在html文件中导入带有<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>的<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>用户界面。
https://stackoverflow.com/questions/53383310
复制相似问题