- Sep 24, 2017
- 5
- 5
I have decided to try making a game with HTML, vanilla JS, and CSS, essentially a web page presenting as a visual novel. Not looking for alternatives like Renpy or TyranoBuilder at the moment.
Everything works fine when hosted, but not when I open my index.html directly. When assets need to be loaded, be it images, video, audio, I get this error:
The way I am displaying images, video, and playing audio is nothing special, looks something like this:
I see Twine Sugarcube projects able to open from index.html without issues loading assets, and am wondering how they do it, or some other solution that allows the game load assets even when index.html is opened directly.
More details in case it matters, the project consists of 1 HTML file, 1 JS file, and 1 CSS file. Pages are merely divs being displayed and hidden.
Everything works fine when hosted, but not when I open my index.html directly. When assets need to be loaded, be it images, video, audio, I get this error:
Code:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file: *filepath* (Reason: CORS request not http).
Code:
<img src="./myImage.png">
<video src="./myVideo.mp4" loop></video>
<audio src="./myAudio.ogg"></audio>
More details in case it matters, the project consists of 1 HTML file, 1 JS file, and 1 CSS file. Pages are merely divs being displayed and hidden.
Last edited: