Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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
简单HTML5画布不工作_Html_Visual Studio - Fatal编程技术网

简单HTML5画布不工作

简单HTML5画布不工作,html,visual-studio,Html,Visual Studio,当我从visualstudio 2012 express运行firefox时,为什么它不能在我的firefox中运行呢。它在jsfiddle.net中工作 <!DOCTYPE HTML> <html> <head> <title></title> <style> body { margin: 0px; padding: 0px; } &l

当我从visualstudio 2012 express运行firefox时,为什么它不能在我的firefox中运行呢。它在jsfiddle.net中工作

<!DOCTYPE HTML>
<html>
  <head>
      <title></title>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="578" height="200"></canvas>
    <script>
        var canvas = document.getElementById('myCanvas');
        var context = canvas.getContext('2d');

        context.beginPath();
        context.moveTo(100, 150);
        context.lineTo(450, 50);
        context.stroke();
    </script>
  </body>
</html>

身体{
边际:0px;
填充:0px;
}
var canvas=document.getElementById('myCanvas');
var context=canvas.getContext('2d');
context.beginPath();
上下文。moveTo(100150);
lineTo(450,50);
stroke();

在Firefox 18.0.1中为我工作。 您是否尝试直接打开HTML文件?只是为了检查问题是出在浏览器还是visualstudio上

还要检查Firefox中是否启用了JS:

启用和禁用JavaScript

在Firefox中,您可以配置是否允许执行网页中的JavaScript。要在Firefox中允许JavaScript,请执行以下操作:

  • 在Firefox窗口顶部,单击Firefox按钮,然后选择Options
  • 在选项窗口中,选择内容面板
  • 启用JavaScript:选择此选项以允许在计算机上执行Java脚本
  • 要更改高级设置,请单击高级

  • 单击“确定”关闭“选项”窗口


@MarcB询问了JS错误。是否有?

在FF19.0.2中工作正常。检查你的JS错误控制台和什么?在VS2012菜单文件-浏览-Firefox中,工作正常,刚刚在FF 15.0.1和19.0.2中测试过;请注意,VS启动ASP.NET Development server以将页面提供给FF