【发布时间】:2012-03-04 07:42:36
【问题描述】:
我在 html 中有以下代码:
<canvas id="myCanvas" width =800 height=800>
我不想将width 指定为800,而是调用JavaScript 函数getWidth() 来获取宽度,例如
<canvas id="myCanvas" width =getWidth() height=800>
正确的语法是什么?因为我正在做的事情不起作用。
【问题讨论】:
-
您可以与此帖子相关联以获得“适合屏幕”stackoverflow.com/questions/1664785/…
-
您的意思是
<canvas id="myCanvas" width="800" height="800">和<canvas id="myCanvas" width="getWidth()" height="800">。这是代码中的错字还是错误?
标签: javascript html canvas