Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“无法运行”;帆布“;aptana studio中的标记和javascript程序_Javascript_Html_Canvas - Fatal编程技术网

“无法运行”;帆布“;aptana studio中的标记和javascript程序

“无法运行”;帆布“;aptana studio中的标记和javascript程序,javascript,html,canvas,Javascript,Html,Canvas,下面显示的是我的HTMLcode: <!doctype html> <html lang="en"> <title></title> <head> <script scr ="myprog.js"> </script> </head> <body> <section id="main"> <canvas

下面显示的是我的HTMLcode:

<!doctype html>
<html lang="en"> 
   <title></title>
   <head>
      <script scr ="myprog.js"> </script>
   </head>
   <body>
      <section id="main">
         <canvas id="canvas" width="600" height="400"></canvas>
      </section>
   </body>
</html>
根据我的理解,我想在浏览器中得到一个100*200的矩形(我使用的是firefox浏览器)。但是在我的例子中,在运行了上面的代码之后,我得到了一个空白的网页,并且在Aptana studio控制台中也没有得到任何错误。有人能帮我找出问题所在吗

我还尝试运行一个简单的javascript程序,以检查my aptana studio是否可以运行javascript,结果如下:

1) 当我添加一个按钮并尝试使用以下代码调用函数时,我在单击网页上的按钮后收到了警报(即程序工作正常):
试试这个

var x = document.getElementById('canvas');
var canvas= x.getContext('2d');
canvas.rect(10,10,100,200);;
canvas.stroke();
并将脚本置于
标记之前

或者,如果您希望脚本位于顶部,请为其找到jQuery函数

 $( document ).ready(function()

希望我能帮上忙

我不知道问题出在哪里,但当我再次尝试运行它时,它成功了。抱歉打扰了……谢谢你的回复
var x = document.getElementById('canvas');
var canvas= x.getContext('2d');
canvas.rect(10,10,100,200);;
canvas.stroke();
 $( document ).ready(function()