【问题标题】:webcam.js Object doesn't support property or method 'capture'webcam.js 对象不支持属性或方法“捕获”
【发布时间】:2018-03-31 13:44:22
【问题描述】:

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

【问题讨论】:

    标签: jquery webcam.js


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2019-07-05
      • 2015-04-14
      • 2020-09-03
      • 2015-04-09
      • 2014-01-12
      • 2016-08-20
      • 2013-10-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多