tailieunhanh - javascript bible 4th edition jsb gold chapters phần 10

đã thông qua như một mảng gọi một tuyên bố JavaScript lấy một đối tượng tên là thuộc về một container lấy lập chỉ mục đối tượng thuộc một phương pháp thùng chứa tĩnh lấy cửa sổ có chứa Applet của Loại bỏ một đối tượng tên là thuộc về một container | 1192 Part V Putting JavaScript to Work Table 44-1 JSObject Class Methods Method Description call String functionName Object args eval String expression getMember String elementName getSlot Int index getWindow Applet applet removeMember String elementName setMember String elementName Object value setSlot int index Object value toString Invokes JavaScript function argument s passed as an array Invokes a JavaScript statement Retrieves a named object belonging to a container Retrieves indexed object belonging to a container Static method retrieves applet s containing window Removes a named object belonging to a container Sets value of a named object belonging to a container Sets value of an indexed object belonging to a container Returns string version of JSObject Just as the window object is the top of the document object hierarchy for JavaScript references the window object is the gateway between the applet code and the scripts and document objects. To open that gateway use the method to retrieve a reference to the document window. Assign that object to a variable that you can use throughout your applet code. The following code fragment shows the start of an applet that assigns the window reference to a variable named mainwin import . public class myClass extends private JSObject mainwin public void init mainwin this If your applet will be making frequent trips to a particular object you may want to create a variable holding a reference to that object. To accomplish this the applet needs to make progressively deeper calls into the document object hierarchy with the getMember method. For example the following sequence assumes mainwin is a reference to the applet s document window. Eventually the statements set a form s field object to a variable for use elsewhere in the applet Chapter 44 Scripting Java Applets and Plug-ins 1193 JSObject doc JSObject document JSObject form .

TỪ KHÓA LIÊN QUAN