Javascript function not being called in "fiddle"

javascript, jsfiddle

Solution

Because your JavaScript code is in an `onload` handler, which means `display_message` is not global, and therefore not accessible by the HTML.

Since you selected `onLoad`, your JavaScript is injected into the page like this:

window.addEvent('load', function() {
    function display_message(){
        alert("woohoo!");
    }
});

As you can see, `display_message` is only accessible inside that anonymous function. To make the example work, change `onLoad` to `no wrap (head)` or `no wrap (body)` (on the left side of the page).

Working example: http://jsfiddle.net/NZnN2/8/

Problem

I made this short fiddle: http://jsfiddle.net/NZnN2/. Why is it not popping up the alert when I click the button?

Original source