如何通过脚本调用showPreview_1(ele)调用函数?

时间:2013-11-25 13:33:32

标签: php jquery

............................................... .....................................

如何通过脚本调用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>

1 个答案:

答案 0 :(得分:0)

你能试试吗,

        if (this.width != '500')
        {
        alert("not width 500 px.");
            $('input').val("");
        }
        else
        {
            showPreview_1(this);
        }