tailieunhanh - JavaScript Bible, Gold Edition part 30

JavaScript Bible, Gold Edition part 30. 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. | 138 Part III Document Objects Reference On h Example with Listing 15-12 on the CD-ROM Related Items offsetLeft offsetTop offsetHeight offsetwidth properties. outerHTML outerText Value String Read Write NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility One way that Internet Explorer exposes an entire element to scripting is by way of the outerHTML and outerText properties. The primary distinction between these two properties is that outerHTML includes the element s start and end tags whereas outerText includes only rendered text that belongs to the element including text from any nested elements . The outerHTML property contains not only the text content for an element as seen on the page but also every bit of HTML tagging associated with that content. For example consider the following bit of HTML source code P ID paragraph1 How EM are EM you he asked. P The value of the P object s outerHTML property . outerHTML is exactly the same as that of the source code. The browser interprets any HTML tags in a string that you assign to an element s outerHTML property. This means that you can delete set the property to an empty string or replace an entire tag with this property. The document s object model adjusts itself to whatever adjustments you make to the HTML in this manner. In contrast the outerText property knows only about the text content of an element container. In the preceding example the value of the paragraph s outerText property is How are you he asked. If this looks familiar it s because in most cases the innerText and outerText properties of an existing element return the exact same strings. If your audience includes Internet Explorer 4 for the Macintosh be aware that several elements do not support these properties. In addition IE5 Mac is downright buggy when you try to assign new content to either property. Be sure to test your page thoroughly on these platform combinations. Also see Chapter

TỪ KHÓA LIÊN QUAN