Browsers don't allow to read files from the file system directly, without enabling some options, for security reasons.
Personally I don't use emrun. I just open a terminal and run python -m SimpleHTTPServer in the .html folder, and then I point my browser to http://127.0.0.1:8000. Note that, by default, the python simple http server will use port 8000. You can change that with options. On Tuesday, September 22, 2015 at 1:37:11 AM UTC-4, [email protected] wrote: > > This thread helped me. I haven't done a lot of web stuff, so it took me a > while to discover that I needed to use emrun for the file system (FS) stuff > to work. Since I'm using cmake, I added --preload-file and --emrun to my > CMakeLists.txt linker step: > > set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s USE_SDL=2 -o ${PROJECT_NAME}.html > --preload-file ${CMAKE_CURRENT_BINARY_DIR}/@/ --emrun") > > But if you just open the HTML file directly then it gives you an error: > > XMLHttpRequest cannot load file:///H:/code/build-emscripten/pemDemos.data. > Cross origin requests are only supported for protocol schemes: http, data, > chrome, chrome-extension, https, chrome-extension-resource. > > I guess the reason for this error is that the FS (file system) stuff > requires a web server. But if I instead run (emrun --browser chrome > pemDemos.html) then my simple OpenGL ES 2.0 demo works. The (--emrun) is a > nifty bonus to print stdout to my console (eg Windows cmd.exe). cheers for > the mailing list - I found this by searching the mailing list for "cross > origin" :-) > > I'm curious to understand exactly why emrun is necessary... Or if there's > away to change my "browser CORS rules" such that I can just open the html > file directly in the web browser instead of needing to use emrun... > > Next I'm curious whether this will work (without effort) (so anyone can > try my demo on my website from their web browser) when I upload the files > (hello.html, hello.js, hello.data, hello.js.mem) to my web server via > FTP... Of if there is more work I need to do for that to work properly? > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
