PDA

View Full Version : Access to restricted URI denied code 1012



TripperTreats
Jan 16th, 2007, 09:29 PM
Hello all, I am in the unusual situation of knowing EXACTLY what is causing the above error on my page, but I do not know what to do about it. The problem is in a Javascript function that gets any style attribute of any element, whether that style comes from an inline or external stylesheet declaration. The function is this:


function getStyleById (id, property) {
var n = document.getElementById(id);
var s = eval("n.style." + property);
if ((s != "") && (s != null)) return s;
if(n.currentStyle) {
var s = eval("n.currentStyle." + property);
if ((typeof(s) != 'undefined') && (s != "") && (s != null)) return s;
}
var sheets = document.styleSheets;
if(sheets.length > 0) {
for(var x = 0; x < sheets.length; x++) {
var rules = sheets[x].cssRules;
if(rules.length > 0) {
for(var y = 0; y < rules.length; y++) {
var z = rules[y].style;
if((typeof(z) != 'undefined') && ((z[property] != "") && (z[property] != null)) || (rules[y].selectorText == id)) return z[property];
}
}
}
}
return null;
}The only part you need concern yourself with (because it is what is causing the error) is


for(var x = 0; x < sheets.length; x++) {
var rules = sheets[x].cssRules;What is happening is that some extensions of FF (i.e. - the CoComment Extension (http://www.cocomment.com/tools/extension)) will load an external stylesheet after the page has been downloaded, putting the extension's stylesheet at the end of the document.styleSheets array. According to http://stevenharman.net/blog/archive/2006/08/04/The_ATLAS_Framework__Callback_Handler_JavaScript_Bug.aspx this is a problem.

Now that I've told you exactly what the problem is... what can I do? I don't see why this FF behavior matters, as the for loop searches all the stylesheets anyways.

The exact error is

.....................................................
Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://www.trippertreats.com/Scripts/headJavascript.js Line: 35"]
......................................................

Thanks for any help,

david_kw
Jan 16th, 2007, 10:35 PM
It's just a wild guess but that looks kind of like a security model error. Are you by chance loading an external CSS file that comes from a different domain?

david_kw

TripperTreats
Jan 16th, 2007, 10:41 PM
Nope, all my stylesheets are mine, in my own domain. What is a security model error? Something to do with accessing something you're not supposed to? If so, that's what's weird; it's my stylesheet, it's there, etc. By the way, the error is fickle. Sometimes it shows up, sometimes it doesn't (minutes apart on the same computer). I know computers, being as complicated as they are, take on almost human-like complexity (at least we perceive it to be such because we can't see the forest for the trees of code), but how in the world can something so simple as my code produce errors only on certain occasions, when nothing on my end has changed? Artifical intelligence indeed.

david_kw
Jan 16th, 2007, 11:29 PM
I left my computer on your main page for awhile and didn't get the error. Can the main page cause it? Or is it only on some other page?

david_kw

A1ien51
Jan 17th, 2007, 12:00 AM
If you are saying that the extension is adding a stylesheet to the page than are you sure that is in your domain?

Eric

TripperTreats
Jan 17th, 2007, 01:45 AM
Alien: I honestly don't know what the extension is doing; the website I mentioned says only that it adds a stylesheet. Thinking about it, though, perhaps it is external to my stylesheet. I mean, I import all my stylesheets that I need, so what else would such an extension add? But if it really were adding an external sheet, you'd think the maker of the extension would have thought of an access problem.

David: The several times I have seen the error thrown is on the home page when it tries to load that fading slideshow at the bottom. But, this has only been on a library computer at school, and not on my laptop or PC. Thus, you may not have the appropriate crappy extensions of FF that supposedly trigger the error. I've researched online, and there's very little discussion of this other than the fact that it might have to do with an external stylesheet as you've both suggested.

Hmmm... At any rate, all my function is trying to do is determine an object's style, regardless of where that style property comes from. Can you all think of another way to do this besides looping through all the stylesheets? You'd think there would be some absolute, overarching record of an object's style settings.

A1ien51
Jan 17th, 2007, 02:09 AM
Down load Firebug extension
www.getFirebug.com

Open up your page in question and look at the NET tab. See what requests it makes. Also helps showing error messages in better details

Eric

Uzbekjon
Feb 14th, 2009, 09:41 AM
I came across this error as well but mine poped up when I was working with xmlhttprequest object. A quick search (http://www.google.com/search?q=access+to+restricted+uri+denied%22+code%3A+%221012) revealed that the reason was Firefox security. An article on how to resolve access to restricted uri denied" code: "1012 problem (http://jquery-howto.blogspot.com/2008/12/access-to-restricted-uri-denied-code.html) says to upload your files to the server. Solved my problem.

I hope the others who come here from google will also find this message useful.

Upload your file to the server!!!