JavaScript Bible, Gold Edition part 135

JavaScript Bible, Gold Edition part 135. 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. | 1188 Part V Putting JavaScript to Work Listing 44-5 HTML Asking Applet to Read Text File HTML HEAD TITLE Letting an Applet Do The Work TITLE SCRIPT LANGUAGE function getFile form var output output function autoFetch var output if output null O . output return var t setTimeout autoFetch 1000 SCRIPT HEAD BODY onLoad autoFetch H1 Text from a text file. H1 FORM NAME reader INPUT TYPE button VALUE Get File onClick getFile P TEXTAREA NAME fileOutput ROWS 1O COLS 6O WRAP hard TEXTAREA P INPUT TYPE Reset VALUE Clear FORM APPLET CODE NAME readerApplet WIDTH 1 HEIGHT 1 APPLET BODY HTML Because an applet is usually the last detail to finish loading in a document you can t use an applet to generate the page immediately. At best an HTML document can display a pleasant welcome screen while the applet finishes loading itself and running whatever it does to prepare data for the page s form elements. In IE4 the page can then be dynamically constructed out of the retrieved data for NN4 you can create a new layer object and use to install content into that layer. Notice in Listing 44-5 that the onLoad event handler calls a function that checks whether the applet has supplied the requested data. If not then the same function is called repeatedly in a timer loop until the data is ready and the textarea can be set. The APPLET tag is located at the bottom of the Body set to 1 pixel square invisible to the user. No user interface exists for this applet so you have no need to clutter up the page with any placeholder or bumper sticker. Chapter 44 Scripting Java Applets and Plug-ins 1189 Figure 44-3 shows the page generated by the HTML and applet working together. The Get File button is merely a manual demonstration of calling the same applet method that the onLoad event handler calls. Figure 44-3 The page with text .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.