老IE的JavaScript不支持的indexOf [英] Old IE JavaScript doesn't support indexOf
本文介绍了老IE的JavaScript不支持的indexOf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从输入文件类型我传递FULLPATH(整个本地路径名)到JavaScript和我写的JavaScript知道文件扩展类型,
From input file type i am passing fullPath(entire local path name) to javascript , and i have written javascript to know the file extension type ,
while (fullPath.indexOf("\\") != -1)
fullPath = fullPath.slice(file.indexOf("\\") + 1);
alert(fullPath);
我只在上面部分在IE浏览器的问题,正好我发现在IE浏览器不支持的indexOf,我怎么可能会改变我的这一点。如果不是这种情况有没有备用知道文件扩展名可以在所有的浏览器。
I have problem in IE only at above part , exactly i found indexOf is not supported in IE, how may i alter my this . If that is not the case is there any alternate to know the file extension which can work in all browsers.
感谢,结果
michaeld
thanks,
michaeld
推荐答案
您可以创建它(的Javascript code创建方法)
有关易用性:
if(!Array.indexOf){
Array.prototype.indexOf = function(obj){
for(var i=0; i<this.length; i++){
if(this[i]==obj){
return i;
}
}
return -1;
}
}
这篇关于老IE的JavaScript不支持的indexOf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文