Đang chuẩn bị liên kết để tải về tài liệu:
JavaScript Bible, Gold Edition part 167
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
JavaScript Bible, Gold Edition part 167. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | CD-152 Part VI Appendixes outerHTML outerText NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility Example The page generated by Listing 15-13 IE4 Windows only contains an Hl element label and a paragraph of text. The purpose is to demonstrate how the outerHTML and outerText properties differ in their intent. Two text boxes contain the same combination of text and HTML tags that replaces the element that creates the paragraph s label. If you apply the default content of the first text box to the outerHTML property of the labell object the H1 element is replaced by a SPAN element whose CLASS attribute acquires a different style sheet rule defined earlier in the document. Notice that the ID of the new SPAN element is the same as the original H1 element. This allows the script attached to the second button to address the object. But this second script replaces the element with the raw text including tags . The element is now gone and any attempt to change the outerHTML or outerText properties of the labell object causes an error because there is no longer a labell object in the document. Use this laboratory to experiment with some other content in both text boxes. Listing 15-13 Using outerHTML and outerText Properties HTML HEAD TITLE outerHTML and outerText Properties TITLE STYLE TYPE text css Hl font-size 18pt font-weight bold font-family Comic Sans MS Arial sans-serif .heading font-size 20pt font-weight bold font-family Arial Black Arial sans-serif STYLE SCRIPT LANGUAGE JavaScript function setGroupLabelAsText form var content form.textInput.value if content elementObject.outerHTML Appendix F Examples from Parts III and IV CD-153 document.all.labell.outerText content function setGroupLabelAsHTML form var content form.HTMLInput.value if content document.all.label1.outerHTML content SCRIPT HEAD BODY FORM P INPUT TYPE text NAME HTMLInput VALUE SPAN ID label1 CLASS heading Article the First SPAN SIZE 55 INPUT TYPE button VALUE Change Heading HTML onClick .