JavaScript Programmer''''s Reference phần 10 pptx

266 541 0
JavaScript Programmer''''s Reference phần 10 pptx

Đ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

JavaScript Programmer's Reference 2356 Property/method value type: Number primitive JavaScript syntax: N myUrl.y The vertical position of the object in the display measured in pixels. You can use the x and y co- ordinates of the object as targets of the scrollTo() method for the window it lives in. Warnings: ❑ This is withdrawn from Netscape 6.0 and no longer supported. See also: Location.y URN (Definition) A Uniform Resource Name. The URN notation is an alternative means of formatting the URI portion of a URL. This is a standard which is in the process of being defined and deployed. Details are available in RFC 2141. The format is somewhat different to that of a URL placed in an HREF=" " HTML tag attribute. It is not at present widely supported in browsers but may be in the future. See also: UDI, URI, URL User-generated object (Definition) An object created under script control. JavaScript allows the user (or script developer really) to create their own objects, properties and methods. The prototypes for existing built-in objects can also be extended by the script developer. This has generally been supported since the earliest versions of the main JavaScript interpreters. It was made available in the WebTV platform effective from the Summer 2000 release. This means that DHTML effects created by authoring tools such as DreamWeaver should work better in WebTV boxes that are shipped after this date or are upgraded in the field. See also: JellyScript U – userDefined object (Object/DOM) 2357 userDefined object (Object/DOM) You can define your own objects in several different ways. Availability: DOM level – 1 JavaScript – 1.5 JScript – 5.0 Internet Explorer – 5.0 Netscape version – 6.0 - myObject = new Function() JavaScript syntax: - myObject = new Object() Aside from the ways in which you can create custom objects with your own constructor functions, you can also create your own HTML tags to make custom document elements. Objects are instantiated from HTML tags and assume a class name from the HTML tag names in the document. So you can invent your own tags that become objects in the document model in MSIE, and inherit some basic capabilities from the environment. Netscape version introduces this functionality at version 6.0. See also: Object object userProfile object (Object/JScript) An object that encapsulates a user's profile within the system. Availability: JScript – 3.0 Internet Explorer – 4.0 JavaScript syntax: IE myUserProfile = navigator.userProfile Object methods: addReadRequest(), clearRequest(), doReadRequest(), getAttribute() Through this object, a script can access details about the user from the profile that the system maintains. This is accomplished by the arcane method of queueing requests for access. Then having queued all the requests, you can ask the user for permission with a single dialog. If the user grants permission, you can then access the userProfile values, after which the request queue can be cleared. Warnings: ❑ This is a not fully supported on some versions of MSIE for Macintosh. See also: userProfile.addReadRequest(), userProfile.clearRequest(), userProfile.doReadRequest(), userProfile.getAttribute() JavaScript Programmer's Reference 2358 Method JavaScript JScript N IE Opera Notes addReadRequest() - 3.0 + - 4.0 + - - clearRequest() - 3.0 + - 4.0 + - - doReadRequest() - 3.0 + - 4.0 + - - getAttribute() - 3.0 + - 4.0 + - ? userProfile.addReadRequest() (Method) Adds a request to read a property of the user profile. These are queued up to have permission requested from the user. Availability: JScript – 3.0 Internet Explorer – 4.0 JavaScript syntax: IE navigator.userProfile.addReadRequest (anAttribute) Argument list: anAttribute One of the valid vCard attribute names This method adds a request to the queue. Each request denotes the parameters within the user profile that the script needs to access. You may call this method several times, each time asking for a different user preference. You won't initially be granted access to them until you have executed the doReadRequest() method. If the user affirms that you can access these values, then on its return, you can use the getAttribute() method to access the value you need. You can only access values you have requested and which the user has affirmed. Here is a list of all the user preference attributes that you can request: ❑ vCard.Business.City ❑ vCard.Business.Country ❑ vCard.Business.Fax ❑ vCard.Business.Phone ❑ vCard.Business.State ❑ vCard.Business.StreetAddress ❑ vCard.Business.URL ❑ vCard.Business.Zipcode ❑ vCard.Cellular ❑ vCard.Company ❑ vCard.Department ❑ vCard.DisplayName ❑ vCard.Email ❑ vCard.FirstName ❑ vCard.Home.City ❑ vCard.Home.Country ❑ vCard.Home.Fax ❑ vCard.Home.Phone ❑ vCard.Home.State U – userProfile.clearRequest() (Method) 2359 ❑ vCard.Home.StreetAddress ❑ vCard.Home.Zipcode ❑ vCard.Homepage ❑ vCard.JobTitle ❑ vCard.LastName ❑ vCard.MiddleName ❑ vCard.Notes ❑ vCard.Office ❑ vCard.Pager See also: userProfile object, userProfile.clearRequest(), userProfile.doReadRequest(), userProfile.getAttribute(), vCard object userProfile.clearRequest() (Method) Clear all read requests from the queue. Availability: JScript – 3.0 Internet Explorer – 4.0 JavaScript syntax: IE navigator.userProfile.clearRequest() You should use this as soon as you have retrieved the necessary user information. It purges all pending requests. If you don't use this call, then if you made some more requests, next time you call the doReadRequest() method the user is asked for permission to access an ever increasing list of preferences. See also: userProfile object, userProfile.addReadRequest() userProfile.doReadRequest() (Method) Execute the current queue of read requests, asking the user for permission to access these properties of the profile. Availability: JScript – 3.0 Internet Explorer – 4.0 IE navigator.userProfile.doReadRequest(aCode) IE navigator.userProfile.doReadRequest(aCode, aName) IE navigator.userProfile.doReadRequest(aCode, aName, aDomain) IE navigator.userProfile.doReadRequest(aCode, aName, aDomain, aPath) JavaScript syntax: IE navigator.userProfile.doReadRequest(aCode, aName, aDomain, aPath, anExpire) JavaScript Programmer's Reference 2360 aCode The use code selects an explanatory message aDomain A server domain aName A name denoting who is asking anExpire An expiry date for the permissions Argument list: aPath A document path Having queued some requests to read user preferences of course you would only request access to ones you genuinely needed. Then you should call this method. It presents the user with a dialog asking for permission to access the listed preference values. If the user decides to grant access, you will have access to the user preferences, but only to the ones you have requested. There are a set of optional parameters for this method although the first argument is mandatory. These arguments are: ❑ A usage code. This is a numeric value but it is translated into an explanatory text in the dialog presented to the user. This argument must be present. ❑ The name argument is available so that you can say who you are, when you ask for the permission to access the user profile. ❑ You can specify a server domain, so that the permission granted can be recorded for that domain, to save requests from that domain interrupting the user to ask for the same permission more than once. This lasts for the session or until the expiry date if it is set. ❑ You can specify a document path within which permission granted will apply. This is much like the way that cookies are allowed to be returned only for documents within a path tree. This lasts for the session or until the expiry date if it is set. ❑ The last optional argument is an expiry date up to which time the permissions will be cached and can be used again subject to the domain and path criteria being satisfied. Here is a list of the usage codes for use with the first argument: Code Description 0 System administrator request. 1 Research and development. 2 Complete current transaction. 3 Modify the site content. 4 Improve site content. 5 Notify about updates to the site. 6 Contacting for sales leads. 7 Linking to other information already collected. 8 Other unspecified purposes. 9 Disclosure to other parties for reasons of updating the site. 10 Disclosure to other parties for marketing purposes. 11 Disclosure to other parties for marketing purposes with your permission. 12 Disclosure to other parties for any other purposes. See also: userProfile object, userProfile.addReadRequest() U – userProfile.getAttribute() (Method) 2361 userProfile.getAttribute() (Method) Get an attribute of the vCard object. Availability: JScript – 3.0 Internet Explorer – 4.0 Property/method value type: String primitive JavaScript syntax: IE navigator.userProfile.getAttribute (attribName) Argument list: attribName The name of the required VCard attribute If the user grants access to the userProfile data, this method will return the contents of the named attribute. The same attribute names that were used when the request was queued should be used here. These are all member attributes belonging to the vCard object. You should call this method once for each attribute you need. If you have not been granted access to any attribute you will simply receive a null value. Warnings: ❑ Some documentary sources suggest that this method is largely dysfunctional on a variety of platforms. See also: userProfile object, userProfile.addReadRequest(), vCard object UTC (Standard) Universel Temps Cordonne. See also: Broken down time, Calendar time, Date and time, Daylight savings time adjustment, Universal coordinated time Utility objects (Definition) Netscape Enterprise Server provides server-side utility objects to give assistance when running server-side JavaScript. Refer to: Netscape Enterprise Server Value of an expression (Definition) The result obtained by evaluating an expression. See also: LValue, RValue Value preserving (Definition) The act of converting values from one data type to another should preserve the value with no loss of resolution. See also: Integer promotion Value property (Definition) A property value of an object. Availability: ECMAScript edition – 2 Property/method value type: Depends on value type A value property returns a generally constant value. Examples are the NaN and Infinity values returned by core objects. V Error! No text of specified style in document. 2363 Warnings: ❑ Do not create your own object properties with the same name as internal or core value properties. If you do, unpredictable behavior may result. Internal values should be protected against accidental damage in this way and they would be, if the interpreter designers were infallible. Unfortunately, to date, they have proven to everyone's dissatisfaction that infallibility is a lost art. See also: Global object, Infinity, Internal Property, NaN Cross-references: ECMA 262 edition 2 – section – 15.1.1 ECMA 262 edition 3 – section – 15.1.1 valueOf() (Method) Returns the primitive equivalent value of the receiving object. Availability: JavaScript – 1.1 JScript – 3.0 Internet Explorer- 4.0 Netscape version – 3.0 Property/method value type: Primitive value JavaScript syntax: - myObject.valueOf() The primitive value of the receiving object is returned by this method. This method is supported by virtually all objects due to the fact that it is available as a method of the Global object in Netscape. Therefore it is inherited into the scope chain for every script and function (method). Host implementations will generally override this inherited support and provide specialized output routines that yield a reasonable value. Most likely the value will be a String primitive but it need not be. It could be any of the built-in core primitive data types as specified in the ECMA-262 standard. See also: Array.valueOf(), Boolean.valueOf(), Date.valueOf(), Number, Number.valueOf(), Object.valueOf(), String.valueOf() Chapter number 2364 var (Declaration) A variable declarator. Availability: ECMAScript edition – 2 JavaScript – 1.0 JScript – 1.0 Internet Explorer- 3.02 Netscape version – 2.0 Netscape Enterprise Server version – 2.0 Opera browser – 3.0 - var anIdentifier - var anIdentifier = anInitialVaue - var anIdentifier = anInitialVaue, anIdentifier = anInitialVaue, JavaScript syntax: - var anIdentifier, anIdentifier, anIdentifier The name of a variable. Argument list: anInitialVaue An initial value for the variable The var keyword prefaces a list of variable declarations. The list is terminated by a semi-colon. Variables can be initialized in the declaration list that can declare a single variable or several at once. If the var statement occurs inside a function declaration, the variables are defined with a scope that is local to that function body. Otherwise they are defined with global scope and are created as members of the Global object. When they are created as global variables, they take on the DontDelete property attributes. Variables are created when an execution scope is entered. A block does not indicate a new execution scope, so variables cannot be created local to a code block unless it is a function body. That means they are not local to an if(), while() or for() block of compound statements. When variables are created, they are initialized to contain the value undefined. If an initializer is added to the variable declaration, the value is assigned when the var statement is executed, which may be some time after the execution scope has caused the variable to be created. Warnings: ❑ If you fail to declare a variable with the var keyword, you will end up creating a global variable automatically. If the variable should only have local scope and duration within a function, then you may want to avoid this. ❑ You should use local variables as often as possible to avoid unwanted side effects. Error! No text of specified style in document. 2365 Example code: <HTML> <HEAD> </HEAD> <BODY> <SCRIPT> var myGlobalVariable = 100; function myLocalScope() { var myLocalVariable = 200; } alert(myGlobalVariable); alert(myLocalVariable); </SCRIPT> </BODY> </HTML> See also: = (Assign), Assign value (=), Assignment expression, Assignment operator, Comma operator (,), Compound statement, function( ) , Global object, Initialisation, Semi-colon (;), Statement, Variable Declaration, Variable statement Cross-references: ECMA 262 edition 2 – section – 10.1.3 ECMA 262 edition 2 – section – 12.2 ECMA 262 edition 3 – section – 10.1.3 ECMA 262 edition 3 – section – 12.2 VAR object (Object/HTML) An object representing the HTML content delimited by the <VAR> tags. Availability: JavaScript – 1.5 JScript – 3.0 Internet Explorer- 4.0 Netscape version – 6.0 Inherits from: Element object IE myVAR = myDocument.all.anElementID IE myVAR = myDocument.all.tags("VAR")[anIndex] IE myVAR = myDocument.all[aName] - myVAR = myDocument.getElementById(anElementID) - myVAR = myDocument.getElementsByName(aName)[anIndex] JavaScript syntax: - myVAR = myDocument.getElementsByTagName("VAR")[anIndex] [...]... in a variable, the variable contains only a reference to the object The object's reference count is incremented and is only decremented when a reference to it is discarded To discard the reference to an object that is contained in a variable, it must be deleted explicitly This will not affect the object but will reduce its reference count by one When its reference count is zero, the object can be purged... function( ) , Script Source Text, Variable Declaration Cross-references: ECMA 262 edition 2 – section – 10. 1.3 ECMA 262 edition 3 – section – 10. 1.3 Variable name (Definition) The name of a variable that is unique within a block but not necessarily within the scope chain See also: Variable, Identifier Cross-references: Wrox Instant JavaScript ISBN 1-8 6100 1-27-4 – page – 14 Variable statement (Definition)... Store an object reference in a variable myObject = new Object(); See also: Constant, Function arguments, Garbage collection, Memory leak, Reference counting, Scope, Scope chain Cross-references: ECMA 262 edition 2 – section – 7.5 ECMA 262 edition 2 – section – 10. 1.3 ECMA 262 edition 2 – section – 12.2 ECMA 262 edition 3 – section – 7.6 2367 Chapter number ECMA 262 edition 3 – section – 10. 1.3 ECMA 262... name See also: Declaration, Definition, Formal Parameter List, function( ) , Script Source Text, var, Variable instantiation, Variable statement Cross-references: ECMA 262 edition 2 – section – 10. 1.3 ECMA 262 edition 3 – section – 10. 1.3 O'Reilly JavaScript Definitive Guide – page – 53 2368 Error! No text of specified style in document Variable instantiation (Definition) Variables are local to one... Statement, var, Variable Declaration Cross-references: ECMA 262 edition 2 – section – 10. 1.3 ECMA 262 edition 2 – section – 12.2 ECMA 262 edition 3 – section – 10. 1.3 ECMA 262 edition 3 – section – 12.2 VBArray object (Object/JScript) A special JScript object for interacting with Visual Basic or VBScript array data Availability: JScript – 3.0 Internet Explorer- 4.0 JavaScript syntax: IE myVBArray = new... in document Example code: JavaScript > function getArray() dim arrVB(1) arrVB(0) = 100 arrVB(1) = 250 getArray = arrVB End function var vbArr = new VBArray(getArray()); alert(vbArr.dimensions()); Method JavaScript JScript N IE Opera Notes dimensions() - 3.0 + - 4.0 + - - getItem()... property has been referenced"); } else { document.write("A defined property was used"); } See also: Assignment expression, Associativity, javascript: URL, LiveConnect, Operator, Operator Precedence, typeof, Unary expression, Unary operator, undefined Cross-references: ECMA 262 edition 2 – section – 11.4.2 ECMA 262 edition 3 – section – 11.4.2 Wrox Instant JavaScript – page... limitations imposed on the JavaScript supported by the box and the embedded browser does not generally support extensions such as Java, plugins and ActiveX but nevertheless you can still accomplish quite a lot See also: ATVEF, Interpret, JellyScript, Microsoft TV, Platform, Script execution, TV Set-top boxes, Web browser Cross-references: http://developer.webtv.net/authoring /javascript/ javascript.htm 2385... execution apart from how they may affect the interpretation of tokens The placement of whitespace can affect the way an expression is evaluated For example: a = 100 00; Will assign the value 100 00 to the variable a, whereas: a = 10 000; May assign the value 10 to variable a but will likely generate a syntax error unless the interpreter is especially forgiving Strictly speaking the interpreter should reject this:... convention, Lexical element Cross-references: ECMA 262 edition 2 – section - 7.1 ECMA 262 edition 3 – section - 7.2 O'Reilly JavaScript Definitive Guide – page - 28 window (Property) The window object also known as window.window Availability: JavaScript - 1.0 JScript - 1.0 Internet Explorer - 3.02 Netscape - 2.0 Opera - 3.0 Property/method value type: Window object JavaScript syntax: - myWindow.window . variable contains only a reference to the object. The object's reference count is incremented and is only decremented when a reference to it is discarded. To discard the reference to an object. Variable instantiation, Variable statement Cross-references: ECMA 262 edition 2 – section – 10. 1.3 ECMA 262 edition 3 – section – 10. 1.3 O'Reilly JavaScript Definitive Guide – page – 53 Error!. aName, aDomain) IE navigator.userProfile.doReadRequest(aCode, aName, aDomain, aPath) JavaScript syntax: IE navigator.userProfile.doReadRequest(aCode, aName, aDomain, aPath, anExpire) JavaScript Programmer's Reference 2360 aCode The use code

Ngày đăng: 12/08/2014, 19:21

Mục lục

    userDefined object (Object/DOM)

    userProfile object (Object/JScript)

    Value of an expression (Definition)

    VAR object (Object/HTML)

    VBArray object (Object/JScript)

    vCard object (Object/JScript)

    view-source: URL (Request method)

    WebTV (TV Set-top Box)

    Week day (Time calculation)

    Window feature list (Definition)

Tài liệu cùng người dùng

Tài liệu liên quan