title: Uncaught Type Error :Cannot read property 'parentNode' of null
body: <p>I am trying to load examples my instructor posted on his webpage to make sure my laptop can work with WebGL. I opened his examples beforehand and they worked, simply displaying a square in a square. So I went and copied and pasted the exact codes he had onto a notepad text editor, saved them as .js files, then did the same for the .html file and got the error as said in the title above. As I opened "Inspect Element", the part in particular with the error was:</p>
  
  <pre><code>var setupWebGL = function(canvas, opt_attribs) {
    function showLink(str) {
    var container = canvas.parentNode;
  </code></pre>
  
  <p>//Uncaught Type Error :Cannot Readproperty 'parentNode' of null</p>
  
  <pre><code>  if (container) {
      container.innerHTML = makeFailHTML(str);
      }
    };
  
    if (!window.WebGLRenderingContext) {
      showLink(GET_A_WEBGL_BROWSER);
      return null;
    }
  
    var context = create3DContext(canvas, opt_attribs);
    if (!context) {
      showLink(OTHER_PROBLEM);
    }
    return context;
  };
  </code></pre>
  
  <p>Any ideas on how to fix this error? Since this code worked on the instructor's website, there has to be something I am missing. If you need more information/details on the question please let me know. Thanks</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script id="vertex-shader" type="x-shader/x-vertex"&gt;
  
  attribute vec4 vPosition;
  void main()
  {
    g1_Position = vPosition;
  }
  &lt;/script&gt;
  &lt;script id="fragment-shader" type= "x-shader/x-fragment"&gt;
  precision mediump float;
  void main()
  {
     g1_FragColor = vec4(1.0,1.0,1.0,1.0);
  }
  &lt;/script&gt;
  &lt;script type="text/javascript" src="webgl-utils.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="initShaders.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="MV.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="square.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;canvas id="g1-canvas" width="512" height="512"&gt;
  Oops...your browser doesn't support the HTML5 canvas element
  &lt;/canvas&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>