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

JavaScript Bible, Gold Edition part 159 pot

10 229 0
Tài liệu đã được kiểm tra trùng lặp

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 254,89 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

In This Part Appendix A JavaScript and Browser Object Quick Reference Appendix B JavaScript Reserved Words Appendix C Answers to Tutorial Exercises Appendix D JavaScript and DOM Internet

Trang 1

1428 Part V ✦ Putting JavaScript to Work

described earlier, is invoked several times again to derive the quota percentage for the accumulated grand total values in each quarter as well as the complete year.

SELECT controls

To round out the code listing for this application, the values assigned to the two SELECT elements obviously have a lot to do with the execution of numerous func-tions in this application Nothing magic takes place here, but you can see the extent

of the detail required in assigning script-meaningful hidden values, and human-meaningful text for both SELECT elements For example, dividing lines help orga-nize the long sort key list into three logical blocks.

<P>Sort by: <SELECT ID=”sortChooser” onChange=”selectSort(this)”>

<OPTION VALUE=”byRep”>Representative

<OPTION VALUE=”byRegion”>Sales Region

<OPTION

VALUE=””> -<OPTION VALUE=”byQ1Fcst”>Q1 Forecast

<OPTION VALUE=”byQ1Actual”>Q1 Actual

<OPTION VALUE=”byQ1Quota”>Q1 Performance

<OPTION VALUE=”byQ2Fcst”>Q2 Forecast

<OPTION VALUE=”byQ2Actual”>Q2 Actual

<OPTION VALUE=”byQ2Quota”>Q2 Performance

<OPTION VALUE=”byQ3Fcst”>Q3 Forecast

<OPTION VALUE=”byQ3Actual”>Q3 Actual

<OPTION VALUE=”byQ3Quota”>Q3 Performance

<OPTION VALUE=”byQ4Fcst”>Q4 Forecast

<OPTION VALUE=”byQ4Actual”>Q4 Actual

<OPTION VALUE=”byQ4Quota”>Q4 Performance

<OPTION

VALUE=””> -<OPTION VALUE=”byTotalFcst”>Total Forecast

<OPTION VALUE=”byTotalActual”>Total Actual

<OPTION VALUE=”byTotalQuota”>Total Performance

</SELECT>

&nbsp;&nbsp;

Ordered: <SELECT ID=”orderChooser” onChange=”selectOrder()”>

<OPTION VALUE=”inc”>Low to High

<OPTION VALUE=”dec”>High to Low

</SELECT>

</P>

Dreams of Other Views

Confining the example to just one type of view — a table of numbers — should help you grasp the important processes taking place But with the XML data con-verted to JavaScript objects, you can build many other views of the same data into the same page For example, a script could completely hide the numeric table, and generate a different one that draws bar charts for each sales representative or each region (see Chapter 55 for a scripted bar chart example) The horizontal axis would

be the four quarters, and the vertical axis would be dollars or quota percentages Clicking a bar opens a small window or layer to reveal more detail from the sales representative’s record, such as the name of the person’s manager More SELECT

Trang 2

Chapter 57 ✦ Application: Transforming XML Data Islands

elements can let the user select any combination of subsets of the data in either bar

chart or numeric table form to facilitate visual comparisons You might be even

more creative and devise ways of showing the data by way of overlapping

posi-tioned elements.

The point is that despite the kinds of rendering opportunities afforded by the

XSL Transform mechanism (even if you can get comfortable in the syntax and

men-tal model it presents to authors), JavaScript’s detailed access to the DOM offers far

more potential Eventually plenty of content authors will mix the two technologies

by embedding JavaScript into XSL style sheets to supplement XSL features

What About NN6?

Microsoft’s XML data islands are not (yet anyway) part of the W3C DOM As NN6

was being readied for release, there was little imperative to implement this feature

in the browser (very few convenience features of the IE4+ DOM were adopted in

NN6) And, as mentioned elsewhere, without the XML data islands, combining XML

and HTML in the same document is not strictly “legal.” Oddly enough, the example

in this chapter works in NN6, but it is an accident For one thing, the tag names in

the XML data do not overlap with any HTML tag names But don’t take this to mean

you can get away with these kinds of constructions Even if you can force fit your

XML into an HTML document to get it to work, you have no guarantee it will work in

subsequent browser versions.

To combine the powers of JavaScript and the W3C DOM to operate on XML data

in NN6, we have to keep our eyes on availability of the browser’s built-in

capabili-ties for standard XSL Transform facilicapabili-ties Some of it works even in the earliest

releases of the new browser, but what works in NN6 doesn’t work (or work well) in

IE5+, and vice versa Veteran scripters, who bear scars from battles with DOM

incompatibilities, may choose to delay deployments of such content until there is

more unanimity among the latest browsers Browser incompatibilities are

responsi-ble for a massive inflation of object model vocabulary (not to mention the thickness

of this book) Perhaps the day will come when the code we write for even complex

applications will run cleanly on a broad range of installed browsers on a broad

range of devices Don’t give up on the dream.

Trang 4

In This Part Appendix A

JavaScript and Browser Object Quick Reference

Appendix B

JavaScript Reserved Words

Appendix C

Answers to Tutorial Exercises

Appendix D

JavaScript and DOM Internet Resources

Appendix E

What’s on the CD-ROM

VI

Trang 6

JavaScript and

Browser Object

Quick Reference

T he following pages contain reduced printouts of a handy

pamphlet whose Adobe Acrobat ( pdf ) file you can find

on the companion CD-ROM I modified the arrangement of the

following material for printing in this appendix The pdf files

on the CD-ROM, which you can print for quick reference,

con-tain all of the pages you see in this appendix.

This compact guide enables you to see at a glance the

breadth of each object’s properties, methods, and event

han-dlers The core JavaScript language section applies to all

scriptable browsers The document object model, however, is

divided into the three basic model types that developers must

support:

✦ Fully compatible with all browsers

✦ Internet Explorer proprietary object model

✦ W3C DOM-compatible browsers

As a measure of how much the language — and especially

the object models — have grown in recent times, the same

quick reference for the previous edition of this book

amounted to four printable sides This edition requires no

fewer than 12 sides.

The large vocabularies and divisive nature of the existing

object models (complicated ever further in the IE browser

due to operating system incompatibilities) create a major

challenge in designing a portable, quick reference like the one

shown on the following pages Object model groupings in the

Quick Reference are designed to be as consistent as possible

across the three models; so if you attempt to build

applica-tions for multiple object models, you can find, say, the

document object’s property listings in similar positions in

each of the three model references Development for the IE4+

and W3C DOM environments still requires knowledge about

the original object model because that legacy model persists

in current practice.

A

A P P E N D I X

Trang 7

1434 Part VI ✦ Appendixes

To conserve space in the IE4+ and W3C DOM sections, I do not list all HTML ele-ment objects (even though I cover them in chapters of this book) A large percent-age of HTML elements share the same properties, methods, and event handlers — all of which are listed in each object model’s section (in a box labeled “All HTML Elements”) For example, the DIV element has a specific role and behavior from the point of view of the HTML rendering engine; however, as a scriptable object, it has

no properties, methods, or event handlers beyond the ones it shares with all HTML elements Therefore, the only HTML elements that I list within the IE4+ and W3C DOM sections are those that have one or more properties, methods, and event han-dlers that are either unique to that object or are shared by only a few related ele-ments Once you are acquainted with the items in common with all elements, it is easier to find the items that are special to a listed object.

If you choose to print the Acrobat files, first read the CD-ROM file Choose a Version.txt to determine the format you’d like to print Then read the

howtoprt.txt file in the folder dedicated to your chosen format This file contains printing and assembly directions for optimum convenience with respect to the for-mat you choose.

Trang 8

Appendix A ✦ JavaScript and Browser Object Quick Reference

(1)Method of the static String object parameter; second parameter (limit integer) to limit the number of space character.

big() bold()

italics() lastIndexOf("

strike() substr(

sup() toLocaleLowerCase()

global input

length prototype

prototype description

MAX_VALUE MIN_VALUE NEGATIVE_INFINITY prototype

getYear() getMonth() getDay() getMinutes() getTime() getMilliseconds()

getTimezoneOffset() toDateString()

random() round(

Functions decodeURI("

Statements const

} result

[break] [default :

N4, IE4 label :

}] [finally {

Trang 9

1436 Part VI ✦ Appendixes

Comparison == Equals

- Minus / Divide % Modulo Decrement

Assignment +=

Boolean || OR Bitwise

new this

Borders & Edges border

JavaScript and Browser Objects Quick Reference

This guide contains quick reference info for the core JavaScript language, the original document object model (2 pp), the IE4+DHTML object model (4 pp), and the W3C DOM object model(4 pp) as implemented in IE5+ and NN6 All-uppercase object names refer to HTML elements (IE4+ and W3C DOMs) The three columns in each box list the object’s properties,methods, and event handlers in that order Read the compatibility guides for each section Numbers in the upper left corners of object squares are chapter numbers in which the object is covered in detail Basic browser and operating system notation codes are as follows: N — Netscape Navigator

See the accompanying file for printing and collating instructions in booklet or broadside configurations

Trang 10

Appendix A ✦ JavaScript and Browser Object Quick Reference

clear() close()

alinkColor applets[]

bgColor domain

fgColor height

linkColor location

referrer URL

(1) Replaced by the URL property in Navigator 3 (3) mimetype parameter new in M4, but only "text/html" type supported.

onBlur onLoad onMouseOver

frames[] innerHeight

(1)New window specs for all browsers: height, width, toolbar, location, directories, status, menubar, dependent, hotkeys, innerHeight, innerWidth, outerHeight, outerWidth, screenX, screenY, titlebar(S), (2)Optional args parameter added to N4; 3rd parameter in IE4 is for scripting language.

onAbort onError

(1) Implemented in IE3.01/Macintosh but not Windows until IE4. hash hostname pathname protocol target

onMouseOut onMouseOver

Reserved. JSB4

clearTimeout(ID) confirm("

Ngày đăng: 06/07/2014, 06:20

TỪ KHÓA LIÊN QUAN