I'm trying to develop an application that will use getImageData in javascript in Firefox 3, but I am getting a "NS_ERROR_DOM_SECURITY_ERR
" on the getImageData call. The javascript and the image are both currently being served from by hard drive, which is apparently a security violation? When this is live they will both be served from the same domain, so it won't be a problem, but how can I develop in the meantime?
views:
1867answers:
3
+2
A:
You could try installing a local webserver such as Apache (on unix) or IIS (on Windows). That will ultimately give you the best local test bench for web-related stuff, because as you have found out browsers treat files from the filesystem quite differently than content served from a webserver.
Marc Novakowski
2008-12-11 06:06:45
Good idea, I'll start running Apache (I'm on OS X).
lacker
2008-12-11 06:12:17
+3
A:
You can tell the browser to bug off. The solution is better or worse depending on your circumstances. I wrap it in a try so no security dialog will be presented if it's not an issue.
var data;
try {
try {
data = context.getImageData(sx, sy, sw, sh).data;
} catch (e) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
data = context.getImageData(sx, sy, sw, sh).data;
}
} catch (e) {
throw new Error("unable to access image data: " + e);
}
Justin Love
2008-12-14 12:34:17
I'm playing with asp.net on one localhost port and editing css dragged in from another localhost port, and this is helping me get around, otherwise I couldn't access document.styleSheets[x].cssRules. big thanks!
Assembler
2010-08-06 06:49:43
A:
In Firefox, type "about:config" into your address bar. Then use the search field to search for "security.fileuri.strict_origin_policy". Double click this to set it to "false".
rogerh
2010-08-06 15:19:00