2014-02-21 99 views
0

我目前遇到一些與OOP JavaScript相關的IE8錯誤。一切工作正常在IE9 +,鉻,火狐等我也試圖找到類似的問題,在stackoverflow,但失敗。OO JS對象不支持此屬性或方法在IE8中

代碼:

$(function(){ 
    // Notification 
    OPD_Notification = function(selector) { 
     this.selector = selector; 
    } 

    OPD_Notification.prototype.setText = function(text) { 
     $(this.selector).find('.container').text(text); 
    }; 

    OPD_Notification.prototype.setStatus = function(status) { 
     $(this.selector).addClass(status); 
    } 

    OPD_Notification.prototype.removeStatus = function(status) { 
     $(this.selector).removeClass(status); 
    } 

    OPD_Notification.prototype.show = function() { 
     $(this.selector).slideDown(200); 
    }; 

    OPD_Notification.prototype.hide = function() { 
     $(this.selector).slideUp(200); 
    }; 

    // Notification 
    notification = new OPD_Notification('#notification'); 
}); 

問題: IE8引發我一個錯誤Object doesn't support this property or method,當我嘗試做以下操作:notification = new OPD_Notification('#notification');我猜它可能是做與jQuery,但真的不知道。

就像我運行代碼低音,它在IE8中工作正常。

function Rabbit(line) { 
    this.line = line; 
} 

Rabbit.prototype.speak = function() { 
    alert(this.line); 
}; 

rbt = new Rabbit("Well, now you're asking me."); 
rbt.speak(); 

關於我在做什麼錯誤的任何提示,將有很大幫助。謝謝。

JSFiddle

+1

你的變量應該是全球性的嗎? – elclanrs

+0

@elclanrs是的。因爲我想在其他一些功能中使用它。 –

+0

這是否有幫助:https://github.com/socketstream/socketstream/issues/283#issuecomment-7835157 – Oleg

回答

0

不知道怎麼了,不知道爲什麼。但我已將notification = new OPD_Notification('#notification');更改爲prefixNotification = new OPD_Notification('#notification');並開始工作。

相關問題