我正在为医生创建web应用程序。在患者治疗页面上,我使用了jquery向导(jquery.steps.min.js)插件来逐步诊断。在最后一步中,我使用了网络摄像头jquery插件,当我点击捕获照片按钮时,它给出了一个错误对象不支持属性或方法‘捕获’
如果我在测试页面或向导的第一步使用没有向导的摄像头插件,它工作得很好。但如果使用第二步或第三步,则会出现上述错误。下面是我的jquery代码。在webcam.capture();行出错
<script src="/js/jquery-2.1.1.js"></script>
<!-- WebCam -->
<script src="/js/webcam/jquery.webcam.js"></script>
<script>
var pageUrl = "treatment.aspx";
$(function () {
jQuery("#webcam").webcam({
width: 320,
height: 240,
mode: "save",
swffile: "/js/webcam/jscam.swf",
debug: function (type, status) {
$('#camStatus').append(type + ": " + status + '<br /><br />');
},
onSave: function (data) {
$.ajax({
type: "POST",
url: pageUrl + "/GetCapturedImage",
data: '',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
$("[id*=imgCapture]").css("visibility", "visible");
$("[id*=imgCapture]").attr("src", r.d);
},
failure: function (response) {
alert(response.d);
}
});
},
onCapture: function () {
webcam.save(pageUrl);
}
});
});
function Capture() {
webcam.capture();
return false;
}
</script>
发布于 2018-10-03 03:48:20
尝试将网络摄像头声明(如下所示)放在页面加载上。
jQuery("#webcam").webcam({
width: 320,
height: 240,
mode: "save",
swffile: "/js/webcam/jscam.swf",
debug: function (type, status) {
$('#camStatus').append(type + ": " + status + '<br /><br />');
},
onSave: function (data) {
$.ajax({
type: "POST",
url: pageUrl + "/GetCapturedImage",
data: '',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
$("[id*=imgCapture]").css("visibility", "visible");
$("[id*=imgCapture]").attr("src", r.d);
},
failure: function (response) {
alert(response.d);
}
});
},
onCapture: function () {
webcam.save(pageUrl);
}
});
https://stackoverflow.com/questions/49588430
复制相似问题