title: blocked a frame of origin "null" from accessing a cross-origin frame - chrome
body: <p>I'm new to Javascript and am learning the basics via a textbook that focuses on its applications in IE 7+ and Firefox 2+. However, I am using Chrome and am getting the following error when running the program given in the book: "blocked a frame of origin 'null' from accessing a cross-origin frame." Can anyone tell me what is causing the error and how I can fix it? The two programs are below.</p>
  
  <pre><code>//This is the program being loaded into the browser
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;Example&lt;/title&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function calcFactorial(factorialNumber){
      var factorialResult = 1;
      for(;factorialNumber&gt;0;factorialNumber--) factorialResult *= factorialNumber;
      return factorialResult;
  }
  
  &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;frameset cols="100%,*"&gt;
  &lt;frame name="fraCalcFactorial" src="calcfactorial.htm"/&gt;
  &lt;/frameset&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Below is the src file</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;Example&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  function butCalculate_onclick(){
      try{
          if (window.top.calcFactorial == null)
              throw "This page is not loaded within the correct frameset";
          if (document.form1.txtNum1.value == "")
              throw "!Please enter a value before you calculate its factorial";
          if (isNaN(document.form1.txtNum1.value))
              throw "!Please enter a valid number";
          if (document.form1.txtNum1.value &lt; 0)
              throw "!Please enter a positive number";
      }
      catch(exception){
          if (typeof(exception) == "string"){
              if (exception.charAt(0) == "!"){
                  alert(exception.substr(1));
                  document.form1.txtNum1.focus();
                  document.form1.txtNum1.select();
              }
              else alert(exception);
          }
          else alert("The following error occurred: " + exception.message);
      }
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="" name="form1"&gt;
      &lt;input type="text" name="txtNum1" size="3" /&gt; factorial is
      &lt;input type="text" name="txtResult" size="25" /&gt;&lt;br/&gt;
      &lt;input type="button" value="Calculate Factorial"
          name="butCalculate" onclick="butCalculate_onclick()" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>