views:

77

answers:

2

Hello,

I'm running into a scenario where at random times I am getting "Access Denied" when executing javascript. It is not repeatable and occurs in random places of my application. There is not indication of what is causing it in the logs and I'm really at a loss on this. It seems to be UI problem only. However, there is no reason it should appear as I do not have any such permission checking to could be getting triggered.

Thanks in advance

+1  A: 

Remember JavaScript has to load information from the exact same domain, as it is running on.

Hope this helps.

Eibx
+3  A: 

If you're trying to access the window objects of other frames, or do ajax requests to load information from other sites, etc., you'll get access denied errors unless 1) The resource is from the same origin, or B) You're using a CORS-enabled browser, the resource supports CORS, and it allows you access.

I can't immediately think of other access denied errors in JavaScript, so I'd look hard at any place you're trying to access other window objects or doing Ajax requests.

This is a big stretch (and not intended to be MS-bashing), but if you're only seeing this on IE and not other browsers, IE has an issue with conflating the id and name namespaces on pages, so if (for instance) you have an iframe on a page with the same name as the id of something else on your page and you're trying to access the other thing, IE may think you're trying to access the iframe -- which would be an access issue if the iframe contains content not adhering to the SOP. Again, a stretch, but I've seen people run into id vs. name issues with IE so many times... Microsoft's page on getElementById says that this is an issue in IE6 and IE7 but not in IE8, so that's a positive move.

T.J. Crowder