Are you running the code from a local file? i.e. navigating to c:\html\test.html (or equivalent) in the browser.
It doesn't appear to work when doing this for me either, however when I hosted the HTML file on a webserver (I used tomcat) and navigated to http://localhost:8080/html/test/html
it worked.
Edit: This would explain why it works fine on JS Fiddle as well