0

我正在为医生创建 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>
4

1 回答 1

0

尝试将网络摄像头声明(如下)放在页面加载中。

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);
             }
         });

于 2018-10-03T03:48:19.543 回答