当我想检测IE时,我使用此代码:
function getInternetExplorerVersion()
{
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
function checkVersion()
{
var msg = "You're not using Internet Explorer.";
var ver = getInternetExplorerVersion();
if ( ver > -1 )
{
msg = "You are using IE " + ver;
}
alert( msg );
}
Run Code Online (Sandbox Code Playgroud)
但IE11正在返回"你没有使用Internet Explorer".我该如何检测它?
debugging internet-explorer browser-detection forward-compatibility internet-explorer-11
我遇到了麻烦
<!--[if !IE]>
Run Code Online (Sandbox Code Playgroud)
上班.我想知道是不是因为我的文件中有这个
<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]> <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]> <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
当我添加
<!--[if !IE]><!-->
<link type="text/css" rel="stylesheet" href="/stylesheets/no-ie.css" />
<!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我的标题不起作用.但是,如果我添加
<!--[if !IE]><!-->
<style>
All my css in here
</style>
<!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
到实际的html页面(在标题中)它的工作原理.有什么建议?干杯
更新我的问题
好吧,当我删除时,
<!-->我只检查了IE工作,但现在回到FF中,no-ie.css也已应用于FF.所以我添加回来<!-->并删除了/(并将其添加到主模板中,因此cms不会将其添加回来)并且所有都在FF中工作但现在样式表正在应用于IE!所以我试过了
<!--[if IE]>
<link type="text/css" rel="stylesheet" href="/stylesheets/no-ie.css">
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
和
<!--[if !IE]> -->
<link type="text/css" rel="stylesheet" href="/stylesheets/no-ie.css">
<!-- <![endif]-->
Run Code Online (Sandbox Code Playgroud)
那没用.基本上我正试图让这个页面工作 …
我如何检查用户浏览器是否为IE?我在这里有这个代码,但它不起作用.
if($.browser.msie && $.browser.version <= 9)
{
alert('You Are Using An Outdated Browser! Switch To Chrome Or FireFox.');
}
Run Code Online (Sandbox Code Playgroud) 感谢另一位成员的帮助,我成功实现了一个JS方法,该方法能够粘贴excel数据并将其拆分为HTML文本框表格(参见线程).
我现在面临的问题是这只在Chrome中有效,而IE10和IE11都标记了以下错误:
"无法获取未定义或空引用的属性'getData'."
该函数的第二行(下面)抛出此错误:
function (event) {
var input_id = $(this).attr("id");
var value = event.originalEvent.clipboardData.getData('text/plain'); //ERROR in IE
/* ... */
event.preventDefault(); // prevent the original paste
}
Run Code Online (Sandbox Code Playgroud)
想知道是否有人可以看到手头的问题,为什么Chrome满足而IE不满足.
从上一个问题我发现下面的代码可以确定用户是否有IE,然后运行特定于它们的js代码.但是当我在我的网站上使用代码时,效果恰恰相反.在其他浏览器上,代码被触发,在IE上没有.我究竟做错了什么?
<![if !IE]>
<script type="text/javascript">
$(document).ready(function() {
$(".box.2").fadeOut(1500);
});
</script>
<![endif]>
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
$(document).ready(function () {
$('body a[href]').qtip({
hide: {
fixed: true,
delay: 500
},
style: {
classes: 'qtip-dark qtip-shadow'
},
position: {
viewport: $(window)
}
});
jQuery.each(jQuery.browser, function (i, val) {
$("<div>" + i + " : <span>" + val + "</span>")
.appendTo(document.body);
});
});
Run Code Online (Sandbox Code Playgroud)
除上述代码外,如果从此浏览器功能中检测到Internet Explorer,我将如何运行脚本?如果检测到Internet Explorer,我想运行的脚本是:
$(document).ready(function () {
$('body a[href]').qtip({
hide: {
fixed: true,
delay: 500
},
style: {
classes: 'qtip-dark qtip-shadow'
}
});
Run Code Online (Sandbox Code Playgroud)