JavaScript is case sensitive, HTML is not.
Code:
<script type="text/javascript">
/*Using an anonymous function */
document.body.onresize=function() {
alert('bingo?');
document.body.onresize= MyFunction; // so after the first resize we will have a new event handler.
};
function MyFunction() {
alert('bingo!');
}
</script>
That will work. I'd suggest you stick to the proper method names, that is to the all-lowercase ones -- even if it is HTML code. Imagine one day migrating to an XML DOM instead and finding out that it too is case sensitive. Plus there can be no confusion if you call the same things by exactly the same name.
The second problem you have here, is that with your assignment you turned an object method into an object property with the value "MyFunction()". You may want to read some JavaScript tutorials because it is a fairly elemental mistake (and one you'll probably never make again). The correct syntax to use is: object.method = functionName; See the example code above for, well, an example.
EDIT: Just in case you were wondering. Of course you can simply set the event listener to MyFunction straight away.
Bookmarks