我有一个特定的代码,它在 Google chrome 上运行良好,但在 IE9 上运行良好。我有一个 div,我将图像从计算机拖到 div 并在 Google Chrome 上加载,但在 IE9 上不加载。请帮忙..!
<div id="holder" ></div>
<p id="status">
Please Drag your image from computer and paste it on the div to view it.
</p>
</div>
jQuery:
var holder = document.getElementById('holder'),
state = document.getElementById('status');
if (typeof window.FileReader === 'undefined') {
state.className = 'fail';
} else {
state.className = 'success';
state.innerHTML = 'Please Drag your image from computer and paste it on the div to view it.';
}
holder.ondragover = function () {
this.className = 'hover';
return false;
};
holder.ondragend = function () {
this.className = '';
return false;
};
holder.ondrop = function (e) {
this.className = '';
e.preventDefault();
var file = e.dataTransfer.files[0],
reader = new FileReader();
reader.onload = function (event) {
alert(event);
console.log(event.target);
holder.style.background = 'url(' + event.target.result + ') no-repeat center';
};
console.log(file);
reader.readAsDataURL(file);
return false;
};
可能是什么问题呢??