Why does this simple JSFiddle not work?
You need to take your function out of the onLoad/onReady otherwise it is placed inside of another scope and your button cannot access the function. In your case you need to use No wrap (head)
The code generated looks like this:
Ext.onReady(function() {
function displaymessage()
{
alert("Hello World!");
}
});
Change the code to run "no wrap (head)" instead of "onDomReady". Your function isn't visible to your markup as is.
Select No wrap - bottom of <head>
in the “Load type” dropdown in the JavaScript settings.