简体   繁体   English

面向对象的javascript和IE7问题

[英]object oriented javascript and IE7 issue

function fake()
{
var ffake;
}

fake.prototype.abc = function()
{
   fake.ffake = 1;//not working in IE7 but seems to be working in all others
}

var myNewObject = new fake();  

Because of the script is breaking on that instant, can not move forward. 由于脚本在那一瞬间中断,无法前进。

firstly i am not getting reason and then i spend almost more then 2 hrs on google to figure out the solution. 首先,我没有理由,然后我在Google上花费了将近2个小时,以找出解决方案。

Any help will be appreciated 任何帮助将不胜感激

Try changing: 尝试更改:

fake.ffake = 1;

To: 至:

this.ffake = 1;

Example: 例:

function fake()
{
  var ffake;
}

fake.prototype.abc = function()
{
   this.ffake = 1;
   alert(this.ffake);
}

var myNewObject = new fake();  
myNewObject.abc(); // alerts "1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM