2

I wrote a widget that includes javascript from one site, on another. The code is:

<script type="text/javascript" src="http://www.easionline.com/min/?f=widget.js"></script> 

In IE9, everything displays perfectly, but in IE8, I get this error:

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2;
.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0;
InfoPath.2)

Timestamp: Fri, 13 Jul 2012 07:20:30 UTC

Message: Access is denied.

Line: 7
Char: 73
Code: 0
URI: http://www.easionline.com/min/?f=widget.js

Anybody know why IE8 would give me a message denied problem? If you want to see a site where the widget is implemented, visit http://www.ham.co.za

If you execute it without the minifying:

<script type="text/javascript" src="http://www.easionline.com/widget.js"></script> 

I get this error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2;
.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0;
InfoPath.2)

Timestamp: Fri, 13 Jul 2012 07:49:41 UTC
Message: Access is denied.

Line: 98
Char: 3
Code: 0
URI: http://www.easionline.com/widget.js

Line with the error says:

96: var ajaxUrl = site_root+"ajax/widget/"+affid+"/"+category+"/"+numproducts;
97: 
98: obj.open("GET",ajaxUrl,true);
99: obj.send(null);

Please note, for various reasons I am avoiding Jquery for this task. So the question really boils down to: Why does this ajax call work in IE9 but not IE8?

rockstardev
  • 13,479
  • 39
  • 164
  • 296
  • 2
    you have an error in your JS, not with how it is loaded... you should un-minify your JS and try again to get a proper line number for the error – JamesHalsall Jul 13 '12 at 07:39
  • I updated it with more info. It looks like that ajax function can't be called. Why would it be a "access denied" error?!` – rockstardev Jul 13 '12 at 08:29
  • could you tell me what the `obj` variable is? – JamesHalsall Jul 13 '12 at 12:03
  • 1
    Check out http://www.easionline.com/widget.js for all the info. But to answer it quickly ==> obj=pullAjax(); – rockstardev Jul 13 '12 at 12:13
  • possible duplicate of [Access denied to jquery script on IE](http://stackoverflow.com/questions/5087549/access-denied-to-jquery-script-on-ie) – kapa Jul 13 '12 at 12:43

1 Answers1

0

This solved my problem: Access denied to jQuery script on IE

Basically, IE requires you to use XDomainRequest instead of XHR. So I replaced:

obj=pullAjax();
  obj.onreadystatechange=function() {
    if(obj.readyState==4) {
        // etc
    }
}
obj.open("GET",ajaxUrl,true);
obj.send(null);

With:

xdr = new XDomainRequest(); 
xdr.onload=function()
{
    // etc
}
xdr.open("GET", thisUrl); 
xdr.send([data]); 

... BUT only for IE. I had to use Javascript to detect if it is IE because I can't use jQuery for this specific project. So I used this:

var browserName=navigator.appName; 
if (browserName=="Microsoft Internet Explorer") ...

src: http://www.pageresource.com/jscript/jbrowse.htm

Community
  • 1
  • 1
rockstardev
  • 13,479
  • 39
  • 164
  • 296