在ie9中上传获取js错误:SCRIPT5007:预期的对象

san*_*eep 16 javascript internet-explorer uploadify internet-explorer-9

我想在div上绑定uploadify.
当我点击上传按钮时,它显示我的错误SCRIPT5007: Object expected.

对于下面的演示检查,链接在ie9中拖动div时产生错误

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.20/jquery-ui.js"></script>
<script type="text/javascript" src="http://www.uploadify.com/wp-content/themes/uploadify/js/jquery.uploadify.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

身体

<div class="container" id="container">
    <div id="uploadify-item"></div>
    This container is not draggable in IE9 but it works in Chrome and FF. Why not?
</div>
Run Code Online (Sandbox Code Playgroud)

JS

$('#uploadify-item').uploadify({
    'swf'      : 'http://www.uploadify.com/uploadify/uploadify.swf',
    'uploader' : 'http://www.uploadify.com/uploadify/uploadify.php'
});
$("#container").draggable();
Run Code Online (Sandbox Code Playgroud)

参考:http://jsfiddle.net/axzdR/19/

eHu*_*ain 19

IE9似乎有SWFUpload嵌入的错误,如果您尝试在元素上调用"getAttribute/removeAttribute/setAttribute",则会引发"预期的对象"错误.我发现swfupload.js中的cleanUp()函数从IE9中的对象DOM中删除了所有js函数,包括"getAttribute/removeAttribute/setAttribute".

解决此问题

在SWFUpload.prototype.cleanUp中

更改:

if (typeof (movieElement[key]) === "function")
Run Code Online (Sandbox Code Playgroud)

至:

if (typeof (movieElement[key]) === "function" && key[0] <= 'Z') // Remove only Flash functions (starts with capital letters). 
Run Code Online (Sandbox Code Playgroud)

uploadify的修补版本保留在此位置

http://www.dariowiz.com/scripts/jquery.uploadify3.1Fixed.js

问候.