[英]if IE Condition Doesn't Work
I have 2 sections of code for IE and other (Chrome, FF). 我有IE和其他(Chrome,FF)代码的2个部分。 I am using IE8 and it is STAYING outside
<!--[if IE]>... <![endif]-->
, any function inside ... doesn't work. 我正在使用IE8,并且在
<!--[if IE]>... <![endif]-->
外面停留,里面的任何功能都无法正常工作。 However, it is GOING inside <!--[if !IE]><!-->....<!--<![endif]-->
, which I don't expect it goes through. 但是,它正在
<!--[if !IE]><!-->....<!--<![endif]-->
,我不希望它会通过。 (I also try some more syntax such as <!-- [if !IE] -->...<!-- [endif] -->
but it seems not ignore!). (我还尝试了其他语法,例如
<!-- [if !IE] -->...<!-- [endif] -->
但似乎不能忽略!)。
I don't know for sure if <meta>
tags cause the problems. 我不确定
<meta>
标签是否会引起问题。 Please take a look. 请看一下。
<head>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"/>
<meta content="no-cache; post-check=0; pre-check=0" http-equiv="Cache-Control"/>
<meta content="no-cache" http-equiv="Pragma"/>
<meta content="Thu, 01 Dec 1994 16:00:00 GMT" http-equiv="Expires"/>
<!--[if IE]>
<script>
$(document).ready(function() {
$(".exportExcel").click(function(e) {
e.stopPropagation();
var table = $("." + $(this).data('target'));
var strCopy = $('<div></div>').html(table.clone()).html(); window.clipboardData.setData("Text", strCopy);
var objExcel = new ActiveXObject("Excel.Application");
objExcel.visible = false;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
objExcel.visible = true;
});
});
</script>
<![endif]-->
<!--[if !IE]><!-->
<script>
$(document).ready(
function()
{
$(".exportExcel").click(function(e) {
e.stopPropagation();
var table = $("." + $(this).data('target'));
window.open('data:application/vnd.ms-excel,' + $(table).html());
e.preventDefault();
});
}
);
</script>
<!--<![endif]-->
Turn off your compatibility mode in IE8, then try. 在IE8中关闭兼容模式,然后尝试。 It may only work in standard and quirks modes.
它只能在标准和怪异模式下工作。
Have you tried adding the meta tag <meta http-equiv="X-UA-Compatible" content="IE=edge">
您是否尝试过添加元标记
<meta http-equiv="X-UA-Compatible" content="IE=edge">
These are all the tags on our page and it works 这些都是我们页面上的所有标签,它可以正常工作
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
IE conditionals are no longer supported in IE, as of 10 从10开始,IE中不再支持IE条件
https://msdn.microsoft.com/en-us/library/ie/hh801214(v=vs.85).aspx https://msdn.microsoft.com/zh-CN/library/ie/hh801214(v=vs.85).aspx
If it's just JavaScript, then you can check for the browser version and run a different function depending on the browser. 如果只是JavaScript,则可以检查浏览器版本并根据浏览器运行其他功能。
<script>
$(document).ready(navigator.appName == 'Microsoft Internet Explorer' ?
function(){ /* IE code */ } :
function(){ /* Non-IE code */ });
</script>
Other ways to detect IE: 检测IE的其他方法:
console.log($.browser.msie);
console.log('ActiveXObject' in window);
console.log(!!window.navigator.userAgent.match(/(MSIE |Trident\/)\d+/));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.