Java script only works remotely, not locally

I have this file on my server that works as it should:

When you click on the outlined Rhino, a modal window appears and you can drag the cursor to color the rhino. It also works when I preview the file from hype to either my desktop browser or to my iPad via Hype Reflect.

However, when I use the exact same files as in the link above and try to view it locally, then the Java script and the “scratch” function stops working. Not sure why it does work locally when previewing from Hype, but when opening the HTML file locally then it doesn’t. Any ideas?

This is what I get when viewing locally from the HTML.

We would need to see the code and project. Also have you looked for errors in the console of the browser.

Hi Mark,

There were no errors in the Console. However, my concern was that I would get same error when creating a Phone Gap app since files are also stored locally. But I did a quick test yesterday and it works when the files are converted into an .ipa.

I don’t know why it does not work locally on my desktop, but is not an important issue anymore.


It's mostly because of CORS. You can read more about it on the internet, but, in in-short, if you want to preview your files locally, you need to host them on a local web server (that's what Hype does). Running JavaScript on local HTML files is now blocked in most latest browsers.

that makes sense. Thank you!

1 Like