html local file opened in firefox does not run javascript function
Hello,
I am creating an html page, which is stored into my computer, and on opening it with Firefox, a javascript function that should run when the page opens, it doesn't. It does in chrome, but in Firefox it doesn't (77.0.1 (64bit)).
The definition of the function is not inline. Other than that, it is a regular function.
Any clues?
I do not have any add ons installed in firefox.
Thank you in advance,
Diego
All Replies (2)
Is your JavaScript path absolute or relative? It needs to be relative.
Absolute would probably have a /
slash at the front. It doesn't work because that sends Firefox looking back to the root directory. On a website that would be the domain name, but on a local HTML file that's the root of your drive.
Relative would be using ..
double dots to navigate to the JavaScript file from where the local HTML file is stored.
You can check the Web Console for possible error messages.
- "3-bar" menu button or Tools -> Web Developer
- https://developer.mozilla.org/en-US/Tools/Web_Console