JQuery签名不适用于IE< = 9

时间:2014-03-04 09:11:19

标签: javascript jquery internet-explorer

我正在使用JQuery Singature,我在上面的IE版本中遇到了这个错误消息:

Message: Canvas element does not support 2d context. jSignature cannot proceed.

更新:在flashcanvas.js中添加(;)之后

问题是一样的:

消息:预期';'
    flashcanvas.swf

Code: 0

我已从

下载了flashcanvas.swfflashcanvas.js

https://github.com/brinley/jSignature/blob/master/libs/flashcanvas.js https://github.com/brinley/jSignature/blob/master/libs/flashcanvas.swf

这两个文件我将它们放在名为Script的文件夹中。

如果我包含或不包含flashcanvas.swf无关紧要我需要做什么?

这里是javascript

 <!--[if lte IE 9]>
  <script type="text/javascript" src="Script/flashcanvas.js"></script>  
  <script type="text/javascript" src="Script/flashcanvas.swf"></script> 
<![endif]-->  

<script type="text/javascript" src="Script/jSignature.js"></script>   

<script type="text/javascript">

    $(document).ready(function (){
    $("#divSignature").jSignature({width:400, height:140, mousedown:function(){}});
    });

</script>

1 个答案:

答案 0 :(得分:1)

只是语法错误,只需在flashcanvas.js的第928行更新以下内容:

function getSwfUrl(window) {
    return ( (window[FLASH_CANVAS + "Options"] || {})["swfPath"] || BASE_URL ) + "flashcanvas.swf"; //Added semicolon
}
对于Javascript错误,IE往往不那么宽容,这对于学习该语言的程序员来说是一件好事。像Chrome这样的浏览器可以容纳相当数量的JS错误,并且仍能正确执行脚本。