The problem is specific to JSFiddle. You need to change the LOAD TYPE to No wrap - bottom of <body>.
When using onLoad, the function won’t become global one, so you can’t invoke it directy from HTML. If it is global – like when using no-wrap – it works.
solved html button not calling its onclick js function