IE8浏览器对indexof()函数的兼容性
function showSelected(){
//在页面加载时添加被选中职员
//alert('select')
var staffs = $(".list input[type=checkbox]:gt(0)");
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++)
{
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
} 按照百度上面把这段代码贴在使用indexof()函数前面,还是不可以解决IE8浏览器的兼容性问题?
staffs.each(function(){
if(staffIds.indexOf(this.id)>-1){在IE8中这个地方老是提示对象不支持此属性或方法
$(this).attr('checked',true);
}else{
//alert('jj')
$(this).attr('checked',false);
}
});
if($(".list input[type=checkbox]:checked").size()==$(".list input[type=checkbox]").size()-1){
$(".selectAll").attr('checked','true');
}
}
求大神帮忙,急急急!!!!
//在页面加载时添加被选中职员
//alert('select')
var staffs = $(".list input[type=checkbox]:gt(0)");
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++)
{
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
} 按照百度上面把这段代码贴在使用indexof()函数前面,还是不可以解决IE8浏览器的兼容性问题?
staffs.each(function(){
if(staffIds.indexOf(this.id)>-1){在IE8中这个地方老是提示对象不支持此属性或方法
$(this).attr('checked',true);
}else{
//alert('jj')
$(this).attr('checked',false);
}
});
if($(".list input[type=checkbox]:checked").size()==$(".list input[type=checkbox]").size()-1){
$(".selectAll").attr('checked','true');
}
}
求大神帮忙,急急急!!!!
...全文
相关推荐
js代码判断浏览器种类IE、FF、Opera、Safari、chrome及版本
主要分享了判断IE、FF、Opera、Safari、Chrome等浏览器和版本的两种方法,需要的朋友可以参考下
JS如何判断浏览器类型和详细区分IE各版本浏览器
今天用到JS判断浏览器类型,于是就系统整理了一下,便于后期使用。 /* * 描述:判断浏览器信息 * 编写:LittleQiang_w * 日期:2016.1.5 * 版本:V1.1 */ //判断当前浏览类型 function BrowserType() { var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器 var isIE = userAgent.ind
IE浏览器检测的方法.docx
IE浏览器检测的方法.docx
非常详细的JS判断浏览器的版本和型号
这个txt文件你下载之后可以直接改后缀运行看效果的,当前市场上的各个浏览器基本都可以判断,包括IE的不同版本也有判断!
利用js判断浏览器类型(是否为IE,Firefox,Opera浏览器)
我们开发的人来说经常要加个判断,要不可能某些功能没法正常使用。要是没加个判断就会给大家带来些麻烦



