170 likes | 320 Vues
ACM 511. IntroductION to CLIENT-SIDE WEB PROGRAMMING. Javascript. Javascript. Javascript. Determining the Length of a String. Changing the Case of a String. Searching a String: indexOf ( ) Technique. Extracting Part of a String with slice( ). Extracting Part of a String with slice( ).
E N D
ACM 511 IntroductION to CLIENT-SIDE WEB PROGRAMMING ACM 262 Course Notes
Javascript ACM 262 Course Notes
Javascript ACM 262 Course Notes
Javascript ACM 262 Course Notes
Determining the Length of a String ACM 262 Course Notes
Changing the Case of a String ACM 262 Course Notes
Searching a String: indexOf( ) Technique ACM 262 Course Notes
Extracting Part of a String with slice( ) ACM 262 Course Notes
Extracting Part of a String with slice( ) ACM 262 Course Notes
Document Object Model When a Web browser loads an HTML file, it displays the contents of that file on the screen (appropriately styled with CSS, of course). But that’s not all the Web browser does with the tags, attributes, and contents of the file: it also creates and memorizes a “model” of that page’s HTML. In other words, the Web browser remembers the HTML tags, their attributes, and the order in which they appear in the file—this representation of the page is called the Document Object Model, or DOM for short. The DOM provides the information needed for JavaScript to communicate with the elements on the Web page. The DOM also provides the tools necessary to navigatethrough, change, and add to the HTML on the page. The DOM itself isn’t actually JavaScript—it’s a standard from the World Wide Web Consortium (W3C) that most browser manufacturers have adopted and added to their browsers. The DOM lets JavaScript communicate with and change a page’s HTML. ACM 262 Course Notes
Selecting Page Elements ACM 262 Course Notes
Selecting Page Elements ACM 262 Course Notes
DOM Relationships ACM 262 Course Notes
DOM Relationships ACM 262 Course Notes
DOM Relationships ACM 262 Course Notes
Example 5.1 ACM 262 Course Notes
Problem with DOM A further complication is that the major browsers interpret the DOM differently.The techniques presented in the earlier pages of this chapter are all cross-browsercompatible, but other parts of the DOM standard aren’t. For example, InternetExplorer handles events differently from other browsers; the same HTML can producemore text nodes in Firefox and Safari than in Internet Explorer; and IEdoesn’t always retrieve HTML tag attributes in the same way as Firefox, Safari, orOpera. In addition, different browsers treat white space (like tabs and spaces) in HTML differently—in some cases treating white space like additional text nodes(Firefox and Safari) and in other cases ignoring that white space (InternetExplorer). And those are just a few of the differences between how the most commonWeb browsers handle the DOM. ACM 262 Course Notes