bug*_*kar 5 javascript html5 google-chrome ios
我正在使用一些非常简单的html5和js代码通过从移动浏览器中单击按钮来拍照,并将其发送到Web服务。这部分代码可在Ios(Ipad)的Safari中完美运行。此外,代码还可以在Chrome浏览器的桌面和桌面移动模式下完美运行。
在Ios上的Chrome浏览器中;
这是html部分:
<tr id="photo-functions-row">
<td></td>
<td>
<div style="max-width:30%">
<label for="take-photo" class="custom-file-upload">
<i class="fa fa-cloud-upload"></i> Take Photo
</label>
<input type="file" accept="image/*" capture="camera" id="take-photo" onchange="readURL(this);" />
<button id="clear-photo" type="button" onclick="clearPhoto();" class="ui-btn ui-btn-inline" style="margin:5px;">Clear Photo</button>
<button id="save-photo" type="button" onclick="savePhoto();" class="ui-btn ui-btn-inline" style="margin:5px;">Save Photo</button>
</div>
</td>
<td>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
这是js部分:
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img-placeholder')
.attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
function savePhoto() {
let files = document.getElementById("take-photo").files;
let reader = new FileReader();
reader.readAsDataURL(files[0]);
reader.onload = function (e) {
let base64Image = e.target.result;
console.log(base64Image);
let params = [];
let CalID = calItem.id;
params[0] = CalID;
params[1] = base64Image;
sendPhoto(params);
};
}
function sendPhoto(params) {
var json = jQuery.post(savePhotoWebServiceAddress,
{
jsonData: JSON.stringify(params)
}).done(function (data) {
let photomessage = "";
try {
var obj = jQuery.parseJSON(data);
if (obj != null) {
if (obj.success == true) {
photomessage = photoMessageSuccess;
}
else {
photomessage = photoMessageFailed;
}
}
} catch (e) {
photomessage = "An exception occured: " + e.message;
}
alert(photomessage);
clearPhoto();
});
}
Run Code Online (Sandbox Code Playgroud)
在Ios上的Chrome浏览器中应该有一些特定的中断执行。
归档时间: |
|
查看次数: |
177 次 |
最近记录: |