JavaScript execution does not take effect when loading rectangles,Change the function to take effect.

Not effective:

javascript:
    function createDrawingCanvas(id, width, height) {
      var canvas = document.getElementById(id);
      var ctx = canvas.getContext('2d');
      canvas.width = width || 500;
      canvas.height = height || 350;
      ctx.lineWidth = 3;
      ctx.lineJoin = ctx.lineCap = 'round';
      var isDrawing, drawLine;
      canvas.onmousedown = function(event) {
        isDrawing = true;
        drawLine = { x: event.clientX, y: event.clientY };
      };
      canvas.onmousemove = function(event) {
        if (!isDrawing) return;
        ctx.beginPath();
        ctx.moveTo(drawLine.x, drawLine.y);
        ctx.lineTo(event.clientX, event.clientY);
        ctx.stroke();
        drawLine = { x: event.clientX, y: event.clientY };
      };
      canvas.onmouseup = function() {
        isDrawing = false;
      };
    };
    createDrawingCanvas([[This.name]], [[This.width]], [[This.height ]]);

 

The following functions take effect:

javascript:
function test() {
  alert("Javascript runs");
};
test();
最新提问 12月 13, 2023 用户: axuew

1个回答

0 赞同
createDrawingCanvas([[This.name]], [[This.width]], [[This.height ]]);

 

There is an additional space after “This.height”

最新回答 12月 13, 2023 用户: AxureShop官方

相关问题

1 回答
最新提问 1月 26, 2021 用户: 189****7909 | 1,962 浏览
1 回答
最新提问 4月 22, 2019 用户: 匿名用户 | 3,024 浏览
1 回答