标签:window ons substr ref efi load case indexof webkit
//建立一個可存取到該file的url function getObjectURL(file) { var url = null; if (window.createObjectURL != undefined) { // basic url = window.createObjectURL(file); } else if (window.URL != undefined) { // mozilla(firefox) url = window.URL.createObjectURL(file); } else if (window.webkitURL != undefined) { // webkit or chrome url = window.webkitURL.createObjectURL(file); } return url; } $(document).on(‘change‘, ‘.wishfile‘, function () { var _upload_file = $(this).val().toLowerCase(); var _upload_file_hz = _upload_file.substr(_upload_file.lastIndexOf(‘.‘) + 1); var _upload_file = [‘jpg‘, ‘png‘, ‘gif‘, ‘jpeg‘]; if ($.inArray(_upload_file_hz, _upload_file) < 0) { alert(‘上传格式不正确‘); $(this).val(‘‘); return false; } var objUrl = getObjectURL(this.files[0]); //console.log("objUrl = " + objUrl); if (objUrl) { // img src=objUrl } });
标签:window ons substr ref efi load case indexof webkit
原文地址:http://www.cnblogs.com/benlightning/p/6136933.html