Can't get JS Fiddle to work, why?

Here is a JS game I am trying to make with vanilla JS.

But it will not run in JS fiddle, anyone know why?

The window load event gets dispatched only once, and since the JS in the fiddle already runs on load by default, your window.onload function will never get called. You can adjust how to load the JS by clicking that JAVASCRIPT button though.

That is because of, in JS fiddle there is an option, when to load the javascript. In your fiddle it is set to onload and your script will be triggered once the window in loaded.
And in your javascript you have window onload event which will never be executed because already onload event is fired before execution of the script.
So to fix this either change the option of jsfiddle to domready or remove the onload event in your script.

Hope this helps :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.