title: SCRIPT70: Permission denied Accessing iFrame in IE
body: <p>I am having some issues in IE with uploading files through a hidden iFrame. Actually the file upload is working fine but my jQuery code to display the success dialog and add the link to a table is not firing. Using the IE developer tools I discovered SCRIPT70: Permission denied error message. This is working fine in Chrome so I'm at a loss to what the issue is in IE. I should mention I am using IE10 so I imagine the issue exist in the previous versions of IE as well.</p>
  
  <p>Essentially what I am trying to do is simulate Ajax like file upload using a hidden iFrame since we have to support legacy browsers. When the iFrame post successfully its response has a div which contains JSON which I read then parse. The data from the JSON is used to display a message to the user indicating the status of the file upload as well and add the link to the page by adding a row to a table. However in IE the chechUploadResponse function does not even appear to be firing.</p>
  
  <p>Javascript:</p>
  
  <pre><code>$(document).ready(function()
  {
  $('#btnPrint').click(openPrintTimesheetWindow);
  $('#date').change(postback);
  $('#employee').change(postback);
  $('#client').change(postback);
  $('#btnUpload').click(uploadFile);
  $("#uploadFrame").on("load", function () {
      $('#uploadFrame').contents().find('#userFile').change(uploadFileChanged);
      checkUploadResponse();
      });
  });
  
  function postback()
  {
  $('#timesheetPrintFilter').submit();
  }
  
  function uploadFileChanged()
  {
  $('#ajaxBusy').show();
      $('#uploadFrame').contents().find('#uploadForm').submit();
  }
  
  function uploadFile()
  {
      var employeeId  = $('#init_employee').val();
      var periodDate  = $('#init_periodEndDate').val();
  
      $('#uploadFrame').contents().find('#employeeId').val(employeeId);
      $('#uploadFrame').contents().find('#periodEndDate').val(periodDate);
      $('#uploadFrame').contents().find('#userFile').click();
  }
  
  function checkUploadResponse()
  {
      var response = $('#uploadFrame').contents().find('#uploadResponse').text();
  
      if (response != null &amp;&amp; response != '')
      {
          var response = jQuery.parseJSON(response);
  
          if (response.status == "ERROR")
          {
              $("#dialog").html(response.message);
              $("#dialog").dialog({ buttons: { "OK": function() { $(this).dialog("close");}}, title: "Error" });
          }
          else
          {
              $("#dialog").html(response.message);
              $("#dialog").dialog({ buttons: { "OK": function() { $(this).dialog("close");}}, title: "Success" });
  
              var url = response.url;
              var tsaid = response.tsaid;
              var name = response.name;
  
              var row = '&lt;tr id="tsaid-' + tsaid + '"&gt;' +
                      '&lt;td width="80%" valign="top" align="left"&gt;' +
                          '&lt;a href="' + url + '"&gt;' + name + '&lt;/a&gt;' +
                      '&lt;/td&gt;' +
                  '&lt;/tr&gt;';
  
              $("#tsAttachment").append(row);
          }
      }
  
      $('#ajaxBusy').hide();
  }
  </code></pre>
  
  <p>Hidden iFrame:</p>
  
  <pre><code>&lt;form id="uploadForm" name="uploadForm" action="timesheet-upload.php" method="POST" enctype="multipart/form-data"&gt;
      &lt;input type="hidden" name="MAX_FILE_SIZE" value="3145728" /&gt;
      &lt;input type="hidden" name="employeeId" id="employeeId" value="" /&gt;
      &lt;input type="hidden" name="periodEndDate" id="periodEndDate" value="" /&gt;
      &lt;input type="file" name="userFile" id="userFile" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is an example response from the hidden iFrame after being posted</p>
  
  <pre><code>&lt;div id="uploadResponse"&gt;{"status":"SUCCESS","message":"Timesheet successfully uploaded","url":"uploads\/2013\/Aug\/1-49cd1c0217abf676505b349ec88bb5a42b1d5631e41232f08be3b0dced9f65e2.pdf","name":"How To Write A Cover Letter.pdf","tsaid":15}&lt;/div&gt;
  &lt;form id="uploadForm" name="uploadForm" action="timesheet-upload.php" method="POST" enctype="multipart/form-data"&gt;
      &lt;input type="hidden" name="MAX_FILE_SIZE" value="3145728" /&gt;
      &lt;input type="hidden" name="employeeId" id="employeeId" value="" /&gt;
      &lt;input type="hidden" name="periodEndDate" id="periodEndDate" value="" /&gt;
      &lt;input type="file" name="userFile" id="userFile" /&gt;
  &lt;/form&gt;
  </code></pre>