Prev | Current Page 736 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

This can be
done by navigating the children of the body field of the js.Lib.document object or more likely by
using the method getElementById() of the Document typedef . This method returns a reference to an
element using a string identifier to locate it; if no element matches the past identifier, a null reference is
returned. Once you obtain such a reference you can change the element contents working on the
innerHTML field or create new child nodes. The HtmlDom , the type associated to every element returned
by using the getElementById() method, also contains fields to query and to change the style of the
element, its attributes, and its events.
The OnLoad Problem
The DOM hierarchy can only be fully manipulated once it has been completely loaded. The page is
downloaded and displayed progressively and the DOM tree is assembled as far as complete elements
have been parsed. The only way to be sure to traverse the tree without receiving errors, is to wait until
the full page is complete. This implies two possible solutions: including the script block at the end
of the page as the very last element or acting on the page load event.


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