Đang chuẩn bị liên kết để tải về tài liệu:
JavaScript Bible, Gold Edition part 196
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
JavaScript Bible, Gold Edition part 196. 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-442 Part VI Appendixes Listing 19-11 continued document.all.counter.innerText i BEGIN UNDO BUFFER CODE buffer global variables var newRanges new Array var origSearchString store original search string and bookmarks of each replaced range function pushUndoNew rng srchString replString origSearchString srchString rng.moveStart character -replString.length newRanges newRanges.length rng.getBookmark empty array and search string global function clearUndoBuffer document.all.counter.innerText 0 origSearchString newRanges.length 0 perform the undo function undoReplace if newRanges.length origSearchString for var i 0 i newRanges.length i rng.moveToBookmark newRanges i rng.text origSearchString document.all.counter.innerText i clearUndoBuffer SCRIPT HEAD BODY H1 TextRange.findText Method H1 HR FORM P Enter a string to search for in the following text INPUT TYPE text NAME searchString SIZE 20 VALUE Law nbsp INPUT TYPE checkbox NAME caseSensitive Case-sensitive nbsp INPUT TYPE checkbox NAME wholeWord Whole words only P P Enter a string with which to replace found text INPUT TYPE text NAME replaceString SIZE 20 VALUE legislation P P INPUT TYPE button VALUE Search and Replace with prompt onClick sAndR this.form P P INPUT TYPE button VALUE Search Replace and Count no prompt onClick sAndRCount this.form TextRange.findText Appendix F Examples from Parts III and IV CD-443 SPAN ID counter Q SPAN items found and replaced. P P INPUT TYPE button VALUE Undo Search and Replace onClick undoReplace P FORM DIV ID rights A NAME article1 H2 ARTICLE I H2 A P Congress shall make no law respecting an establishment of religion or prohibiting the free exercise thereof or abridging the freedom of speech or of the press or the right of the people peaceably to assemble and to petition the government for a redress of grievances. P The rest of the text is snipped for printing here but it is on the CD-ROM version. DIV BODY HTML Having a search and replace function available in a document is only .