I am using an iframe to load a pseudo-ajax file. IFrame is in the same view as javascript loading:
<iframe id="upload_iframe" name="upload_iframe" style="position: absolute; left: -999em; top: -999em;"></iframe>
its operation is “nice” on my local machine, but when I deploy the Azure site, I get the following error in the Chrome debugging console:
Uncaught SecurityError: Failed to read the contentDocument property from "HTMLIFrameElement": the frame with the source " https://acme.azurewebsites.net " was blocked from accessing the frame with the source "zero". Request for access to the frame has the protocol "https", Access to the frame has the protocol for "data". Protocols must comply.
I understand that this iframe has the same origin, since it is strictly local, but how can I convince the browser that it is local? That is, is there something I have to do with the source and protocol of my iframe to avoid this error?
This is my code, in a nutshell:
dataAccess.submitAjaxPostFileRequest = function (completeFunction) {
$("#userProfileForm").get(0).setAttribute("action", $.acme.resource.links.editProfilePictureUrl);
var hasUploaded = false;
function uploadImageComplete() {
if (hasUploaded === true) {
return;
}
var responseObject = JSON.parse($("#upload_iframe").contents().find("pre")[0].innerText);
completeFunction(responseObject);
hasUploaded = true;
}
$("#upload_iframe").load(function() {
uploadImageComplete();
});
$("#userProfileForm")[0].submit();
};
The form userProfileFormhas a property targetset in the iframe. This download layout seems to work for most requests, and I don't know if the “uncaught exception” message is just an observation of a part of Chrome or a potential traffic jam. It cannot be that I can “catch and ignore” such an exception and just show a generic message if this happens?
Profk source
share