............................................... .....................................
如何通过脚本调用showPreview_1(ele)调用函数?
............................................... .....................................
<script language="JavaScript">
var _URL = window.URL || window.webkitURL;
$("#image_1").change(function(e) {
var image_1, img;
if ((image_1 = this.files[0])) {
img = new Image();
img.onload = function() {
if (this.width != '500')
{
alert("not width 500 px.");
$('input').val("");
}
else
{
#### call function showPreview_1(ele) ####
}
};
img.src = _URL.createObjectURL(image_1);
}
});
</script>
<script language="JavaScript">
function showPreview_1(ele)
{
$('#imgAvatar_1').attr('src', ele.value); // for IE
if (ele.files && ele.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imgAvatar_1').attr('src', e.target.result);
}
reader.readAsDataURL(ele.files[0]);
}
}
</script>
答案 0 :(得分:0)
你能试试吗,
if (this.width != '500')
{
alert("not width 500 px.");
$('input').val("");
}
else
{
showPreview_1(this);
}