CD-197Appendix F . Examples from Parts III and IV Now, insert this element before the start of the myPobject: myP.insertAdjacentElement( beforeBegin , a) Notice that you have not assigned an idproperty value to the new element. But because the element was inserted by reference, you can modify the inserted object by changing the object stored in the avariable: a.style.color = red The inserted element is also part of the document hierarchy, so you can access it through hierarchy references such as myP.previousSibling. The parent element of the newly inserted element is the BODY. Thus, you can inspect the current state of the HTML for the rendered page by entering the following statement into the topmost text box: document.body.innerHTML If you scroll down past the first form, you can find the
element that you added along with the STYLEattribute. insertAdjacentHTML( location , HTMLtext ) insertAdjacentText( location , text ) NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility Example Use The Evaluator (Chapter 13) to experiment with these two methods. The example here demonstrates the result of employing both methods in an attempt to add some HTML to the beginning of the myP element. Begin by assigning a string of HTML code to the global variable a: a = Important News! Because this HTML is to go on the same line as the start of the myP paragraph, use the afterBeginparameter for the insert method: myP.insertAdjacentHTML( afterBegin , a) elementObject.insertAdjacentHTML()
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.
This entry was posted
on Sunday, September 30th, 2007 at 6:16 pm and is filed under PHP5.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.