起因:升級了IE11之后部分頁面刷新時會出現"SCRIPT5007: 缺少對象 "的報錯,查看之后發現是Uploadify目前不支持IE11。
查詢到修改源碼以及在插件初始化前try catch調用釋放插件對象的方法,但是依然會出現報錯。
后來在stackoverflow上查詢到可以在頁面頭部添加
<meta http-equiv="X-UA-Compatible" content="IE=edge" > 通過在meta中設置X-UA-Compatible的值,指定IE8/9及以后的版本都會以最高版本IE來渲染頁面。
解決了問題。
付:
修改源碼方法:
源代碼:SWFUpload.prototype.cleanUp = function(a) {try {if (this.movieElement && typeof(a.CallFunction) === "unknown") {this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for (var c in a) {try {if (typeof(a[c]) === "function") {a[c] = null}} catch(b) {}}}} catch(d) {}window.__flash__removeCallback = function(e, f) {try {if (e) {e[f] = null}} catch(g) {}}};修正代碼:SWFUpload.prototype.cleanUp = function(f) {try {if (this.movieElement && typeof(f.CallFunction) === "unknown") {this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for (var h in f) {try {if (typeof(f[h]) === "function" && h[0] >= 'A' && h[0] <= 'Z') {f[h] = null;}} catch(e) {}}}} catch(g) {}window.__flash__removeCallback = function(c, b) {try {if (c) {c[b] = null;}} catch(a) {}};};
2.
部分框架刷新后無法釋放插件的對象,導致二次使用出現文件大小為0、上傳文件隊列累積等問題,該情況解決方法是:在插件初始化前try catch調用插件釋放方法:
在 $('#file_upload').uploadify初始化之前,直接使用下面的效果更好
try {
$('#file_upload').uploadify('destroy');
}catch(e)
{
}