如果用户使用的是 IE 9 及以下版本,则显示 div 和 jQuery
show a div with jQuery if the user is on IE 9 and below
我如何检测(使用 jQuery)用户是否使用 IE 9 或更低版本,以及他们是否 .show()
和 div?
我已经用 jQuery 为 Android 成功完成了以下操作。 我怎样才能做到 IE 9 及以下条件?
完成与 Android. 类似(希望下面的 IE 9 和 有类似的解决方案)
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
// alert( "welcome" );
$("#android").slideDown();
}
您是否尝试过使用这种方法来检测您是否使用 IE?
if ($.browser.msie && parseInt($.browser.version, 10) > 8)
console.log('Using IE9/10');
else
console.log('Not IE9/10');
另一种方法,因为 $.browser 已被弃用:
checkIEVersion();
/**
* Returns the version of Internet Explorer or a -1
* (indicating the use of another browser).
*/
function getIEVersion()
{
var returnValue = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var userAgentValue = navigator.userAgent;
var regExpValue = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (regExpValue.exec(userAgentValue) != null)
returnValue = parseFloat( RegExp. );
}
return returnValue;
}
function checkIEVersion()
{
var returnMessage = "You're not using Internet Explorer.";
var ieVersion = getIEVersion();
if ( ieVersion > -1 )
{
if ( ieVersion >= 9.0 )
returnMessage = "You're using a recent copy of Internet Explorer."
else
returnMessage = "You should upgrade your copy of Internet Explorer.";
}
console.log( returnMessage );
}
Duh...已经有几年了,因为我把其中一个搞砸了..
<!--[if lte IE 9]>
<style>
#ie { display: block !important;}
</style>
<![endif]-->
我如何检测(使用 jQuery)用户是否使用 IE 9 或更低版本,以及他们是否 .show()
和 div?
我已经用 jQuery 为 Android 成功完成了以下操作。 我怎样才能做到 IE 9 及以下条件?
完成与 Android. 类似(希望下面的 IE 9 和 有类似的解决方案)
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
// alert( "welcome" );
$("#android").slideDown();
}
您是否尝试过使用这种方法来检测您是否使用 IE?
if ($.browser.msie && parseInt($.browser.version, 10) > 8)
console.log('Using IE9/10');
else
console.log('Not IE9/10');
另一种方法,因为 $.browser 已被弃用:
checkIEVersion();
/**
* Returns the version of Internet Explorer or a -1
* (indicating the use of another browser).
*/
function getIEVersion()
{
var returnValue = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var userAgentValue = navigator.userAgent;
var regExpValue = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (regExpValue.exec(userAgentValue) != null)
returnValue = parseFloat( RegExp. );
}
return returnValue;
}
function checkIEVersion()
{
var returnMessage = "You're not using Internet Explorer.";
var ieVersion = getIEVersion();
if ( ieVersion > -1 )
{
if ( ieVersion >= 9.0 )
returnMessage = "You're using a recent copy of Internet Explorer."
else
returnMessage = "You should upgrade your copy of Internet Explorer.";
}
console.log( returnMessage );
}
Duh...已经有几年了,因为我把其中一个搞砸了..
<!--[if lte IE 9]>
<style>
#ie { display: block !important;}
</style>
<![endif]-->