1. Trang chủ
  2. » Công Nghệ Thông Tin

JavaScript FOR ™ DUMmIES phần 10 pdf

44 301 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 44
Dung lượng 1,74 MB

Nội dung

sun Description: A top-level object used to access any Java class in the package sun.*. What creates it: Automatically created by Java-supporting browsers. How to access it: Packages.sun (See Packages.) Text Description: A text field included in an HTML form. What creates it: <FORM NAME=”formName”> . . . <INPUT TYPE=”text” NAME=”textName” . . . ></FORM> How to access it: document.formName.textName or formName.elements[i] Properties: defaultValue, form, name, type, value Methods: blur(), focus(), handleEvent(), select() Event handlers: onBlur, onChange, onFocus, onSelect Textarea Description: A text area element (a multiline text input field) included in an HTML form. What creates it: <FORM NAME=”formName”><TEXTAREA NAME=”textarea Name”> . . . </TEXTAREA></FORM> How to access it: document.formName.textareaName or formName. elements[i] Properties: defaultValue, form, name, type, value Methods: blur(), focus(), handleEvent(), select() Event handlers: onBlur, onChange, onFocus, onSelect 323 Appendix C: Document Object Model Reference 29_576593 appc.qxd 10/12/04 10:05 PM Page 323 window Description: A browser window or frame. What creates it: <BODY> <FRAMESET> <FRAME NAME=”frameName”> window.open(“windowName”) How to access it: self window window.frames[i] window.frameName Properties: closed, defaultStatus, document, frames[], history, length, location, Math, name, navigator, offscreenBuffering, opener, parent, screen, self, status, top, window Netscape Navigator only: crypto, innerHeight, innerWidth, jav, location bar , menubar, netscape, outerHeight, outerWidth, Packages, page XOffset , pageYOffset, personalbar, screenX, screenY, scrollbars, statusbar, sun, toolbar Internet Explorer only: clientInformation, event Methods: alert(), blur(), clearInterval(), clearTimeout(), close(), confirm(), focus(), moveBy(), moveTo(), oen(), prompt(), resizeBy(), resizeTo(), scroll(), scrollBy(), scrollTo(), setInterval(), setTimeout() Netscape Navigator only: atob(), back(), btoa(), captureEvents(), disableExternalCapture(), enableExternalCapture(), find(), forward(), handleEvent(), home(), print(), releaseEvents(), routeEvent(), setHotkeys(), setResizable(), setZOptions(), stop() Internet Explorer only: navigate() Event handlers: onBlur, onDragDrop, onError, onFocus, onLoad, onMove, onResize, onUnload 324 Part VI: Appendixes 29_576593 appc.qxd 10/12/04 10:05 PM Page 324 Global Properties Infinity NaN (not a number) Undefined Built-In JavaScript Functions escape() Description: Returns the hexadecimal encoding of an argument in the ISO-Latin-1 character set. The escape() function and it’s reverse function, unescape(), are typically used to send special characters safely from a JavaScript script to another program, such as a Java applet. For example, you can encode a special character by using the escape() function and send the resulting value to another program that can then decode that char- acter by using the equivalent of the unescape() function — and vice versa. (Sending special characters without using this encoding process can result in errors. You can think of the ISO-Latin-1 character set as a lowest-common- denominator language that many programmer languages understand.) Syntax: escape(“valueToBeEncoded”) Example: escape(“&”) // returns the hexadecimal equivalent of & which is “%26” eval() Description: Evaluates a string of JavaScript code without reference to a par- ticular object. Syntax: eval(“value”) where value is a string representing a JavaScript expression, statement, or sequence of statements. The expression can include variables and properties of existing objects. Example: eval(new String(“2+2”)) // returns a String object containing “2+2” 325 Appendix C: Document Object Model Reference 29_576593 appc.qxd 10/12/04 10:05 PM Page 325 isFinite() Description: Evaluates an argument to determine whether it is a finite number. If the argument is NaN, positive infinity or negative infinity, this method returns false; otherwise, it returns true. Syntax: isFinite(value) Example: isFinite(123) // returns true isNaN() Description: Evaluates an argument to determine whether it is not a number. Returns true if passed NaN and false otherwise. Syntax: isNaN(value) Example: isNaN(123) // returns false Number() Description: Converts the specified object to a number. Syntax: Number(anObject) Example: alert (Number(d)) // Displays a dialog box containing “819199440000.” parseFloat() Description: Parses a string argument and returns a floating point number. Syntax: parseFloat(“value”) Example: var x = “3.14” // returns 3.14 326 Part VI: Appendixes 29_576593 appc.qxd 10/12/04 10:05 PM Page 326 parseInt() Description: Parses a string argument and returns an integer of the specified radix or base. (Base 10 is assumed if no radix is supplied.) Syntax: parseInt(string[, radix]) Example: parseInt(“1111”, 2) // returns 15 parseInt(“15”, 10) // returns 15 String() Description: Converts the specified object to a string. Syntax: string(anObject) Example: aDate = new Date (430054663215) alert (String(aDate)) // displays “Thu Aug 18 04:37:43 GMT-0700 (Pacific Daylight Time) 1983.” taint() Description: Adds tainting to a data element or script. (Tainting a JavaScript element prevents that element from being passed to a server without the end-user’s permission.) Syntax: taint([dataElementName]) where dataElementName is the prop- erty, variable, function, or object to taint. If omitted, taint is added to the script itself. Example: taintedStatus=taint(window.defaultStatus) 327 Appendix C: Document Object Model Reference 29_576593 appc.qxd 10/12/04 10:05 PM Page 327 unescape() Description: Returns the ASCII string for the specified hexadecimal encoding value. Syntax: unescape(“value”) where value is a string containing characters in the form “%xx”, xx being a 2-digit hexadecimal number. Example: unescape(“%26”) // returns “&” untaint() Description: Removes tainting from a data element or script. (Tainting a JavaScript element prevents that element from being passed to a server without the end-user’s permission.) Syntax: untaint([dataElementName]) where dataElementName is the property, variable, function, or object from which to remove tainting. Example: untaintedStatus=untaint(window.defaultStatus) 328 Part VI: Appendixes 29_576593 appc.qxd 10/12/04 10:05 PM Page 328 Appendix D Special Characters S ometimes you need to represent special characters in JavaScript strings. Common examples of special characters include white space, currency symbols, and non-English characters. When you represent special characters in JavaScript, you have a choice: You can use escape characters, octal, or hexadecimal representations of the Web-standard character set Latin-1 (ISO 8859-1), or — for versions of Netscape Navigator including 6.0 and later — Unicode. Together, the ISO 8859 and Unicode standards allow for literally tens of thou- sands of special characters: enough to represent most of the known human languages! Although I couldn’t fit all of them in this appendix, the following tables should cover most of your special character needs. It lists the most commonly used special characters, along with both the hexadecimal and octal representations JavaScript supports. Character sets are evolving standards. To get the very latest scoop on JavaScript internationalization and supported character sets — as well as to find representations for special characters not listed in this appendix — check out the section of Netscape’s JavaScript manual that describes support for special characters at http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/ ident.html#1009568 For more information on the Unicode standard, check out the Unicode home page at www.unicode.org The following is example of how you use special characters in JavaScript code: alert(“\’JavaScript For Dummies\u00A9\’ costs $29.99 in the U.S., 195\xA5 in Japan, and \24316 in Britain.”) 30_576593 appd.qxd 10/12/04 10:04 PM Page 329 Here are the most commonly used special characters: Character JavaScript Escape Unicode Characters Apostrophe \’ \u0027 Backslash \\ \u005C Backspace \b \u000b Carriage return \r \u000D Double quote \” \u0022 Form feed \f \u000C New line \n \u000A Tab \t \u0009 Octal, hexadecimal, and Unicode representations of other common special characters appear in the following lists: Octal Hex Unicode Description Character \240 \xA0 \u00A0 Nonbreaking space \241 \xA1 \u00A1 Inverted exclamation mark ¡ \242 \xA2 \u00A2 Cent sign ¢ \243 \xA3 \u00A3 Pound sign £ \244 \xA4 \u00A4 General currency sign € \245 \xA5 \u00A5 Yen sign ¥ \246 \xA6 \u00A6 Broken vertical line _ \247 \xA7 \u00A7 Section sign § \250 \xA8 \u00A8 Diaeresis or umlaut ¨ \251 \xA9 \u00A9 Copyright sign © \252 \xAA \u00AA Feminine ordinal indicator ª \253 \xAB \u00AB Left-pointing double carets « \254 \xAC \u00AC Logical not-sign ¬ 330 Part VI: Appendixes 30_576593 appd.qxd 10/12/04 10:04 PM Page 330 Octal Hex Unicode Description Character \255 \xAD \u00AD Soft hyphen _ \256 \xAE \u00AE Registered sign ® \257 \xAF \u00AF Macron ¯ \260 \xB0 \u00B0 Degree sign ° \261 \xB1 \u00B1 Plus-or-minus sign ± \262 \xB2 \u00B2 Superscript two _ \263 \xB3 \u00B3 Superscript three _ \264 \xB4 \u00B4 Acute accent ´ \265 \xB5 \u00B5 Micron sign > \266 \xB6 \u00B6 Pilcrow ¶ \267 \xB7 \u00B7 Middle dot · \270 \xB8 \u00B8 Cedilla ¸ \271 \xB9 \u00B9 Superscript-one _ \272 \xBA \u00BA Masculine ordinal indicator º \273 \xBB \u00BB Right-pointing double carets » \274 \xBC \u00BC Fraction, one-quarter 1 ⁄4 \275 \xBD \u00BD Fraction, one-half 1 ⁄2 \276 \xBE \u00BE Fraction, three-quarters 3 ⁄4 \277 \xBF \u00BF Inverted question mark ¿ Uppercase Letters \300 \xC0 \u00C0 A-grave À \301 \xC1 \u00C1 A-acute Á \302 \xC2 \u00C2 A-circumflex  \303 \xC3 \u00C3 A-tilde à \304 \xC4 \u00C4 A-umlaut Ä (continued) 331 Appendix D: Special Characters 30_576593 appd.qxd 10/12/04 10:04 PM Page 331 Uppercase Letters (continued) \305 \xC5 \u00C5 A-ring \306 \xC6 \u00C6 AE ặ \307 \xC7 \u00C7 C-cedilla ầ \310 \xC8 \u00C8 E-grave ẩ \311 \xC9 \u00C9 E-acute ẫ \312 \xCA \u00CA E-circumflex ấ \313 \xCB \u00CB E-umlaut ậ \314 \xCC \u00CC I-grave è \315 \xCD \u00CD I-acute \316 \xCE \u00CE I-circumflex ẻ \317 \xCF \u00CF I-umlaut ẽ \320 \xD0 \u00D0 D-stroke _ \321 \xD1 \u00D1 N-tilde ẹ \322 \xD2 \u00D2 O-grave ề \323 \xD3 \u00D3 O-acute ể \324 \xD4 \u00D4 O-circumflex ễ \325 \xD5 \u00D5 O-tilde ế \326 \xD6 \u00D6 O-umlaut ệ \327 \xD7 \u00D7 Multiplication sign ì \330 \xD8 \u00D8 O-slash ỉ \331 \xD9 \u00D9 U-grave \332 \xDA \u00DA U-acute \333 \xDB \u00DB U-circumflex \334 \xDC \u00DC U-umlaut ĩ \335 \xDD \u00DD Y-acute _ \336 \xDE \u00DE THORN _ \337 \xDF \u00DF Small sharp s ( 332 Part VI: Appendixes 30_576593 appd.qxd 10/12/04 10:04 PM Page 332 [...]... these books published by Wiley Publishing, Inc.: PCs For Dummies, by Dan Gookin; Macs For Dummies, by David Pogue; iMacs For Dummies by David Pogue; Windows 95 For Dummies, Windows 98 For Dummies, Windows 2000 Professional For Dummies, Microsoft Windows ME Millennium Edition For Dummies, all by Andy Rathbone Using the CD 1 Insert the CD into your computers CD-ROM drive The license agreement appears... technical support, 21 DOM, 100 101 effect source code, viewing, 11 event properties, 310 events support, 243 351 352 JavaScript For Dummies, 4th Edition Microsoft Internet Explorer (continued) exception handling, 287 HTML tooltip formatting, 201 JavaScript support through JScript, 12, 33, 60 JScript documentation, 270, 276 software, 20 status bar, viewing, 177178 version-specific JavaScript code, 28 writing... and technical support, 21 DOM, 100 101 effect source code, viewing, 11 event properties, 310 events support, 243 exception handling, 287 HTML tooltip formatting, 201 JavaScript support through JScript, 12, 33, 60 JScript documentation, 270, 276 software, 20 status bar, viewing, 177178 version-specific JavaScript code, 28 writing site to meet needs of, 61 The Internet For Dummies (Levine, Baroudi, and... 8486 ease of use of, 11 ECMA standard and, 106 event handlers, 8182 event, predefined, 309 310 file upload element, HTML form (fileUpload), 310 form elements in HTML document (elements[]), 309 functions, 8284 functions, built-in, 325328 global properties, 325 hidden HTML form field (hidden), 311 HTML display frame, 311 HTML document (document), 308309 HTML form, 310 HTML select list option, 317 hyperlink... 217 order form validation script, 224225 expression checking for different values (switch statement), 3941 function, embedding, 43 JavaScript language, 5859 F falls through, interpreter, 41 feedback HTML form, 215 order form validation script, 230 fields, validating independent, 222 file cookie, viewing, 130131 external JavaScript, including, 15 local, problem loading, 281 upload element, HTML form (fileUpload),... 177180 HTML 4 For Dummies (Tittel and Pitts), 11 HTML (HyperText Markup Language) See also frame bugs, tracking, 281282 creating in word processor, 25 display frame, 311 document (document), 308309 errors, common, 262 file, 2528, 3032 form, 215216, 310 hyperlinks, adding ( tag), 197198 JavaScript and, 1415, 17 knowledge required, 11 map, designating active areas, 204205 MARQUEE tag, 106 107 newsgroup,... 219 345 346 JavaScript For Dummies, 4th Edition Dreamweaver (Macromedia), 339 dumping property values, 47 Dynamic HTML See DHTML Dynamic HTML: The Definitive Reference (Goodman), 181 dynamic objects, DOM (Document Object Model), 8486 E EarthWeb online resource, 257 ease of use of JavaScript, 1112 ECMA (European Computer Manufacturers Association) script standard browser, detecting users, 105 106 described,... available for Windows You can find updates at http://www.jasc.com/products/paintshoppro SmartMenus DHTML Menu From SmartMenus.org comes this fast, stable DHTML menu creation tool thats free for use in non-commercial Web sites For conditions of use and sample menus, visit http://www.smartmenus.org/forum/ Web Weaver Demo Version McWeb Softwares Web Weaver is a professional HTML editor for Windows platforms... 44 stepping through multiple items (for loop), 4445 value, returning from, 43 347 348 JavaScript For Dummies, 4th Edition functions, built-in adding tainting to data element or script (taint()), 327 ASCII string, returning for specified hexadecimal encoding (unescape()), 328 converting object to number (Number()), 326 DOM, 325328 finite number, evaluating argument for (isFinite()), 326 floating point... security issues, 126127 343 344 JavaScript For Dummies, 4th Edition cookie (continued) setting (creating), 131133 support, configuring, 128129 surfing sites, 130 view from users perspective, 127131 cross-platform features, 61 cryptography-related digital signature method (crypto), 307 CSS (Cascading Style Sheets) accessing with JavaScript, 86 benefits of using, 8485 defining, 8586 JavaScript, 17 menu class, . Dummies by David Pogue; Windows 95 For Dummies, Windows 98 For Dummies, Windows 2000 Professional For Dummies, Microsoft Windows ME Millennium Edition For Dummies, all by Andy Rathbone. Using. you need more information on the basics, check out these books published by Wiley Publishing, Inc.: PCs For Dummies, by Dan Gookin; Macs For Dummies, by David Pogue; iMacs For Dummies by David. CSS case-sensitivity, JavaScript, 262 catch block, 250–252, 284–287 categories, DOM (Document Object Model), 75–77 342 JavaScript For Dummies, 4th Edition 32_576593 bindex.qxd 10/ 12/04 10: 10 PM Page 342

Ngày đăng: 14/08/2014, 11:20

TỪ KHÓA LIÊN QUAN