“Acecss Denied to content document” error in IE9 with goog.net.IFrameIO

泄露秘密 提交于 2019-12-11 03:56:15

问题


I am trying to use goog.net.IFrameIO to upload a file and get a JSON response from server after uploaded file is processed. It works fine on Chrome and Safari, but does not with work with IE9 where it errors out with "Acecss Denied to content document", then prompts up to save/open the json response. Here is the html code and js code that I have -

HTML Code:

<form action="/" enctype="multipart/form-data" method="POST" id="upload-form">
  <input type="file" name="selected-file" id="selected-file">
  <div role="button" class="test-button>Upload</div>
</form>

JS Code:

test.prototype.uploadFile = function() {
  // Send the form submission to the server using IframeIo to make it feel like
  // AJAX.
  var form = /** @type {HTMLFormElement} */ (goog.dom.getRequiredElement(
      'upload-form'));

  var io = new goog.net.IframeIo();
  goog.events.listen(io, goog.net.EventType.COMPLETE, goog.bind(this.processResponse_, this, io));
  io.sendFromForm(form, '/uploadfile');
}

test.prototype.processResponse = function(io) {
  if (!io.isSuccess()) {
    alert('iframeio error encountered:' + io.getLastError());
    return;
  }
  var response = null;
  try {
    response = io.getResponseJson();
    ..
  } catch (error) {
    ....
}

I am trying to use closure solution only and not other libraries. I have also went through the question at Fallback AJAX file upload for Internet Explorer but was not able to comment on accepted answer for it.

[Troubleshooting]: I see that method goog.net.IframeIo.prototype.onIeReadyStateChange_() is called with ready states like - loading, interactive and then complete, but is not able to get the content document from iframe created for IE.

HTTP Request Headers: Accept: text/html, application/xhtml+xml, / Content-Type: multipart/form-data Accept-Encoding: gzip, deflate

HTTP Response Headers: X-Frame-Options: SAMEORIGIN Content-Type: application/json; charset=utf-8


回答1:


The IframeIO library, for IE(version less than 11) creates an iframe to which the HTTP response is posted after file upload.

But iframe in IE9/10(not sure about 8 or 11) does not accept HTTP response with content-type JSON. The response content-type need to be changed to "text/plain" for IE9/10, to make it work.



来源:https://stackoverflow.com/questions/19901743/acecss-denied-to-content-document-error-in-ie9-with-goog-net-iframeio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!