Skip to content

IE 8 Support Seems to cause Security Exceptions #101

@neosavvy

Description

@neosavvy

Hey there, I have had some great luck with this directive and want to try to work through an IE8 issue I am noticing. Maybe you already have dealt with this.

I am trying to use it in this form:

                        <form action="{{ '/1.0/on_boarding/company/' + organization.company_id}}" ng-upload="completed(content)">
                            <div class="upload-input">
                              <input type="file" name="company_logo" onchange="angular.element(this).scope().fileNameChanged()"></input>
                              <input type="text" name="input" value="logo"></input>
                            </div>
                            <div class="upload-button">
                              <a id="uploadButton" upload-submit class="button" ng-class="$isUploading ? 'disabled' : ''">Upload</a>
                            </div>
                        </form>

This appears to work in Chrome and Firefox. However the following code in ng-upload is having a bit of trouble getting the inner contents of the iframe:

function uploadEnd() {
          // unbind load after uploadEnd to prevent another load triggering uploadEnd
          iframe.unbind('load');
          if (!scope.$$phase) {
            scope.$apply(function() {
              setLoadingState(false);
            });
          } else {
            setLoadingState(false);
          }
          // Get iframe body contents
          var bodyContent = (iframe[0].contentDocument ||
            iframe[0].contentWindow.document).body;
          var content;
          try {
            content = angular.fromJson(bodyContent.innerText || bodyContent.textContent);
          } catch (e) {
            // Fall back to html if json parse failed
            content = bodyContent.innerHTML;
            $log.warn('Response is not valid JSON');
          }
          // if outside a digest cycle, execute the upload response function in the active scope
          // else execute the upload response function in the current digest
          if (!scope.$$phase) {
             scope.$apply(function () {
                 fn(scope, { content: content});
             });
          } else {
            fn(scope, { content: content});
          }
        }

Specifically the

 var bodyContent = (iframe[0].contentDocument ||
            iframe[0].contentWindow.document).body;

Seems as though contentDocument and contentWindow.document are denying access for security reasons in IE8. I wish simply saying IE8 can die would be valid, but in this case I need to make it work. If you guys know of any work around I appreciate it.

I am happy to help dig in here too to fix it as this seems to be a great plugin for uploading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions