Prev | Current Page 737 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The first solution is practical but
tends to be unclear for JavaScript developers who prefer to put their script tags only in the head
397
Chapter 14: More Interactive Content with JavaScript
element; the second one is nicer on this aspect but trickier because of the different implementations
of the events between browsers. To be fair, it is not a difference between modern browsers, but between
Internet Explorer and the rest of the world; nevertheless Internet Explorer deserves its space being by far
the most used web browser.
A Possible Approach for a Cross - Browser Event System
Before implementing an onload solution, what it is needed is to overcome the event handling differences.
The most basic approach to events is to redefine the element methods prefixed with on . It is possible to
perform an action on the click event of a button just by writing something like the following:
import js.Dom;
class Main
{
public static function main()
{
var btn : Button = cast js.Lib.document.getElementById(???sbutton???);
btn.


Pages:
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749