javascript - Blocked from accessing an Iframe with origin 'null' -


i using iframe pseudo-ajax file upload. iframe in same view upload javascript:

<iframe id="upload_iframe" name="upload_iframe" style="position: absolute; left: -999em; top: -999em;"></iframe> 

his works 'nicely' on local machine, when deploy azure web site, following error in chrome's debug console:

uncaught securityerror: failed read 'contentdocument' property 'htmliframeelement': blocked frame origin "https://acme.azurewebsites.net" accessing frame origin "null". frame requesting access has protocol of "https", frame being accessed has protocol of "data". protocols must match.

i understand iframe same-origin, strictly local, how convince browser local? is, there should doing origin , protocol of iframe avoid error?

this code, in 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 userprofileform has target property set iframe. upload arrangement seems work requests, , don't know if 'uncaught exception' message observation on chrome's part, or potential show stopper. there not perhaps way can 'catch , ignore' such exception, , display generic message if happens?

this may depend on browser, iframe element not supported data protocol, see wikipedia entry:

http://en.wikipedia.org/wiki/data_uri_scheme

it may have worked on localhost because localhost can use different authentication & authorization methods (for example on windows may run trusted site, , may pass windows user credentials server automatically, etc.). same origin believe means protocol, host, , port must match. since data protocol different https not same origin, hence security error.

usually data protocol supported these elements:

  • object (images only) (ie: not activex controls)
  • img
  • input type=image
  • link
  • css declarations accept url

can post more of code , problem statement? there multiple other ways accomplish file uploads. example, traditional post method (single file), html5 method (multi files), or using javascript send stream of bytes web service (i did once in activex control used twain scan documents on user's computer , upload scanned image website).


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -