2012-09-26 37 views
1

我在我與工作正常在Firefox和Chrome,但jQuery代碼使用files.length在Internet Explorer中未定義

$(upload_button).bind('change', function(event) 
{ 
    var files = this.files; 
    alert(typeof(files)); 
    if(typeof(files)!='undefined') 
    { 


    } 
}); 

不是在IE8(即IE爲files.length返回undefined,而其他人則返回值)。那麼有人知道如何解決這個問題嗎?

+1

我懷疑'輸入'不是一個好的選擇,因爲IE中的變量標識符... :)但也許它只是我和我越來越老和可疑 – fcalderan

+1

哪個版本的IE? IE6/7/8? '文件'屬性不起作用或'this'? – undefined

+1

好的,代碼的其餘部分(包括'});關閉'bind()'方法)是什麼?哪部分不起作用? –

回答

1

這是因爲Internet Explorer,即使IE9 does not support HTML5 File API因此它返回undefined值爲files屬性。

+0

那麼有沒有可用的黑客? – Stranger

+1

@Udhay我不知道,也許IE10。 http://msdn.microsoft.com/en-us/library/ie/hh772931(v=vs.85).aspx – undefined

1

jQuery API。因爲我假設upload_button是按鈕 change事件將不會與按鈕的工作。

相關問題