11

I am developing an extension for browsers using the Crossrider framework. I am using the line

appAPI.resources.includeJS('js/angular.min.js');

to inject angular.js into the extension. This works fine on Chrome, but on IE 11 I get the error

---- JS Exception from: IE test staging ----
Error: Object expected
Source: Microsoft JScript runtime error
Location: resources
Line: 131

I looked around and found a few answers that suggested that either jQuery might be missing or there might be a trailing comma in the code itself. However, I am using

var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-1.11.3.js";
document.getElementsByTagName('body')[0].appendChild(jq);

to inject jquery into the document, so that shouldn't be a problem. As for the possibility of there being a trailing comma in the JS, I changed from the minified to the unminified version of AngularJS, but still got the same error, which makes me think that the line number in the error is meaningless. If that's the care, or forget that, no matter what the case is. Could someone please tell me what's going on and how to fix it?

PS. My environment is Windows 7 Ultimate 32 bit on VMWare Workstation 12 on a Ubuntu 14.04 LTS x64 bit machine

Irtza.QC
  • 1,026
  • 2
  • 10
  • 23
  • 1
    have you noticed your double-protocol in your jquery url? https://http://code.jquery.com/jquery-1.11.3.js – hereandnow78 Dec 08 '15 at 10:49
  • 1
    this is not a full working example; so people cannot help as much as if they were given a plunker / jsfiddle... – dnozay Dec 14 '15 at 21:33
  • 1
    i cant give a plunkr for this. But you can try it for yourself. go to crossrider.com, sign up for it and add my code into the extension.js file and run it on IE 11 – Irtza.QC Dec 15 '15 at 05:02

1 Answers1

1

I think you have a mixed scopes issue here. appAPI.resources.includeJS runs in the Extension Page scope which the jq element you ate adding runs in the HTML Page scope. If you want to add the AngularJS to the HTML Page scope, use appAPI.resources.addInlineJS as follows:

var jq = document.createElement('script');
jq.src = "https://http://code.jquery.com/jquery-1.11.3.js";
document.getElementsByTagName('body')[0].appendChild(jq);
appAPI.resources.addInlineJS('js/angular.min.js');

[Disclosure: I am a Crossrider employee]

Shlomo
  • 3,763
  • 11
  • 16
  • 1
    I want angular in the extension scope. So why do i get the object expected error? – Irtza.QC Nov 30 '15 at 03:59
  • 1
    Whilst I'm not familiar with AngularJS, from what I can see it doesn't require jQuery. In general, IE is more particular about JS code so it could be that it doesn't like something in the Angular library. I suggest you use the unminified version of Angular and add debugging code to determine exactly where and what's causing the issue. – Shlomo Dec 01 '15 at 14:07
  • 1
    thats over 30k lines of code to debug. I doubt thats possible. – Irtza.QC Dec 07 '15 at 08:49