javascript - Message: Object doesn't support this property or method - Stack Overflow

I am having following error when i open my site on IE 8,Message: Object doesn't support this prope

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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

Object.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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信