1348 Part V . Putting JavaScript to Work (Web server info)

1348 Part V . Putting JavaScript to Work the entire outline HTML to be assigned to the innerHTML property of the empty DIV element delivered with the document. // initialize first time function init(outlineID) { if (supportVerified(outlineID)) { // demo how to get outline head elements var hdr = document.getElementById(outlineID).getElementsByTagName( head )[0] // get outline body elements for iterative conversion to HTML var ol = document.getElementById(outlineID).getElementsByTagName( body )[0] // wrap whole outline HTML in a span var olHTML = + makeHTML(outlineID, ol) + // throw HTML into content DIV for display document.getElementById( content ).innerHTML = olHTML initExpand(outlineID) } } Validation of browser support is handled by the supportVerified() function. This function is in search of the XMLDocumentproperty of the XML element object. The property s presence indicates that the browser has what it takes to treat embedded XML as a data island. Incremental tests are needed so that earlier browsers don t choke on the reference to the property. // verify that browser supports XML islands function supportVerified(testID) { if (document.getElementById && document.getElementById(testID) && document.getElementById(testID).XMLDocument) { return true } else { var reply = confirm( This example requires a browser with XML data island support, such as IE5+/Windows. Go back to previous page? ) if (reply) { history.back() } else { return false } } return false } Accumulating the HTML From the init()function, a call to the makeHTML() function starts the most complex actions of the scripts on this page. This function walks the node hierarchy of the outline s BODY elements, deciphering which ones are containers and which ones are end points. Two global variables are used to keep track of how far the node walk progresses because this function calls itself from time to time to handle nested branches of the node tree. Because a reflexive call to a function starts out with new values for local variables, the globals operate as pointers to let statements in the function know which node is being accessed. The numbers get applied to an ID attribute assigned to the DIV elements holding the content.
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Leave a Reply