I am having following error when i open my site on IE 8,
Message: Object doesn't support this property or method
Line: 25
Char: 13
Code: 0
URI: mycode.js
mycode.js FILE CODE
var LstCompanies = Object.keys(msg);
if (LstCompanies.length > 0) {
any ideas
I am having following error when i open my site on IE 8,
Message: Object doesn't support this property or method
Line: 25
Char: 13
Code: 0
URI: mycode.js
mycode.js FILE CODE
var LstCompanies = Object.keys(msg);
if (LstCompanies.length > 0) {
any ideas
Share Improve this question edited Dec 20, 2013 at 13:54 thefourtheye 240k53 gold badges466 silver badges501 bronze badges asked Jun 26, 2013 at 9:32 user2350607user2350607 131 silver badge5 bronze badges2 Answers
Reset to default 5Object.keys doesnt supported in IE. Here is the safer implementation which is patible with all browsers..
Object.keys = Object.keys || function(o) {
var keysArray = [];
for(var name in o) {
if (o.hasOwnProperty(name))
keysArray.push(name);
}
return keysArray;
};
Your browser (let me guess, it's Internet Exploder on WinXP?) does not support Object.keys
Iterate the old-fashioned way over the object instead.
for (var i in msg){
msg.hasOwnProperty(i){
// Here you have your keys
}
}
or use the shim mentioned in the MDN article.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745259718a4619155.html
评论列表(0条)