Monday, September 19, 2011

Resolving WebGL cross domain image loading error SECURITY_ERR: DOM Exception 18

If u have tried webGL and specially loading textures recently due to the tighter security features you get
 
Uncaught Error: SECURITY_ERR: DOM Exception 18 in Google Chrome and
Error: uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: file:///some directory Line: 46] in Mozilla Firefox

Solution: The solution is quite simple. Just go to command prompt and change directory to where your html page is for example for running WebGL/Simple/Test.html u do this on cmd prompt

c:\> cd D:/WebGL/Simple/
Then simply type this

D:/WebGL/Simple>python -m SimpleHTTPServer

This opens up a local http server, let this cmd prompt run. Now go to the web browser firefox/chrome and type this in the address bar to load the webpage
http://localhost:8000/Test.htm

This should run the WebGL code fine. Once u r done, you can press Ctrl+C to terminate the http server. I hope it helps others from the pain which I had to bear.