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

javascript programmer''''s reference phần 3 ppsx

262 740 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 262
Dung lượng 1,74 MB

Nội dung

D – Document.createCDATASection() (Method) 521 Example code: // A code fragment that creates an attribute and sets it on // an element object that is passed in: function attachMyAttrib(anElement, aName, aValue) { var myNewAttr = createAttribute(aName); var myOldAttr = anElement.setAttributeNode(myAttr); } See also: Attr object, Attribute object Document.createCDATASection() (Method) Creates a new CDATASection object whose value is the string passed as an argument. Availability: DOM level – 1 JavaScript – 1.5 Netscape – 6.0 Property/method value type: CDATASection object JavaScript syntax: N myDocument.createCDATASection(someData) Argument list: someData The data content for the new object See also: CDATASection object Document.createComment() (Method) Creates a new comment node object containing the data passed in the string argument. Availability: DOM level – 1 JavaScript – 1.5 Netscape – 6.0 Property/method value type: COMMENT object JavaScript syntax: N myDocument.createComment(someData) Argument list: someData The content of the comment block See also: COMMENT object JavaScript Programmer's Reference 522 Document.createDocumentFragment() (Method) Creates a new and empty document fragment. Availability: DOM level – 1 JavaScript – 1.5 Netscape – 6.0 Property/method value type: DocumentFragment object JavaScript syntax: N myDocument.createDocumentFragment(someData) Argument list: someData The content of the document fragment See also: DocumentFragment object Document.createElement() (Method) A method to create a new element within a document. Availability: DOM level – 1 JavaScript – 1.5 JScript – 3.0 Internet Explorer – 4.0 Netscape – 6.0 Property/method value type: Element object JavaScript syntax: - myDocument.createElement(aTagName) Argument list: aTagName An HTML tag name The result of calling this method is a new Element object as if it had been freshly instantiated by an HTML tag. This is a means of creating new objects which you can then assign to various properties. It is effectively a constructor which is driven by the HTML tag names. Internally, the MSIE browser maintains objects that are associated with HTML tags as members of a class named after the tag that created them. It’s as if there were a class that corresponded to each HTML tag. This means that a call like createElement() can use them as if they were constructor objects. The internal mechanisms in Netscape 6.0 follow the DOM level 1 specification more closely and use the correct class names as defined in the standards. MSIE may support these in the future and you should be careful when writing any script that needs to be aware of the object class names it is operating on. See also: Document object, Element object D – Document.createEntityReference() (Method) 523 Document.createEntityReference() (Method) A new EntityReference object is created. It may acquire the same child list as the entity it refers to. Availability: DOM level – 1 JavaScript – 1.5 Netscape – 6.0 Property/method value type: EntityReference object JavaScript syntax: N myDocument.createEntityReference(aName) Argument list: aName The name of the entity reference to be created See also: EntityReference object Document.createProcessingInstruction() (Method) A new processing instruction node is created. Its name and content are specified by the arguments. Availability: DOM level – 1 JavaScript – 1.5 Netscape – 6.0 Property/method value type: ProcessingInstruction object JavaScript syntax: N myDocument.createProcessingInstruction (aTarget,someData) aTarget The target for the instruction Argument list: someData The data for the instruction See also: ProcessingInstruction object Document.createStyleSheet() (Method) A style sheet factory method. Availability: JScript – 3.0 Internet Explorer – 4.0 Property/method value type: styleSheet object IE myDocument.createStyleSheet() IE myDocument.createStyleSheet(aURL) JavaScript syntax: IE myDocument.createStyleSheet(aURL, anIndex) aURL The URL to load the style sheet from Argument list: anIndex A location within the stylesheet list to insert this stylesheet JavaScript Programmer's Reference 524 This is a means of adding a style sheet to a document from the JavaScript context. When you create the style sheet, you have the choice of simply creating an empty styleSheet object or calling one in from a URL document source location. You can also specify where in the hierarchy of currently loaded style sheets this new one should be placed by specifying its index location within the styleSheets collection. If you can locate this styleSheet object once it has been installed, you can carry out further modifications on it by means of the addRule() method. This may be somewhat problematic on some browser versions and platforms since you don't get an object reference handle back from this method. You might be able to code around that, however, since you can specify a target index position in the styleSheets collection. That may mean you can get a reference to it indirectly once it has been added. Warnings: ❑ Although this method is supposed to return a styleSheet object, on the Macintosh platform it returns a null value in some versions of the MSIE browser. See also: Document object, StyleSheet object, StyleSheet.addRule() Document.createTextNode() (Method) A means of constructing a new textNode object. Availability: DOM level – 1 JavaScript – 1.5 JScript – 5.0 Internet Explorer – 5.0 Netscape – 6.0 Property/method value type: textNode object JavaScript syntax: - myDocument.createTextNode(someData) Argument list: someData The textual content of the node You may need to create additional text nodes to be placed between other objects you create when modifying a document object model. Text nodes are placed interstitially between object nodes within a document hierarchy. See also: Hierarchy of objects, textNode object D – Document.defaultCharset (Property) 525 Document.defaultCharset (Property) The default character set of the document. Availability: JScript – 3.0 Internet Explorer – 4.0 Property/method value type: String primitive JavaScript syntax: IE myDocument.defaultCharset This would contain the character set being used by the document when it was first opened. That may have changed but this value should always be the same as it was at the start. For example the value "iso-8859-1" is likely to be returned but the local variant of the browser and OS may affect the value you get. Warnings: ❑ Netscape does not support this. See also: Document object, Document.charset Document.designMode (Property) Part of a page authoring control system built into the MSIE browser. Availability: JScript – 5.0 Internet Explorer – 5.0 Property/method value type: Boolean primitive JavaScript syntax: IE myDocument.designMode This is a means of editing objects manually within the browser. While the browser is in this state, editable elements acquire a UI for modification by means of the enter key. When the designMode property is set to "on" you cannot execute scripts. The following values can be assigned to this property: ❑ On ❑ Off ❑ Inherited Warnings: ❑ Whether this works may depend on platform and browser versions. It does not appear to be functional on MSIE for Macintosh despite the Microsoft documentation saying that it should work. JavaScript Programmer's Reference 526 Document.detachEvent() (Method) A means of detaching events from windows and documents that were previously attached with the attachEvent() method. Availability: JScript – 5.0 Internet Explorer – 5.0 JavaScript syntax: IE myDocument.detachEvent(anEventName) Argument list: anEventName The name of an event to be handled This is part of the behavior handling in MSIE which involves the use of style sheets and .htc files. See also: <STYLE>, Document.attachEvent(), Window.attachEvent(), Window.detachEvent() Document.doctype (Property) The current document type of the document. Availability: DOM level – 1 JavaScript – 1.5 JScript – 3.0 Internet Explorer – 4.0 Netscape – 6.0 Property/method value type: Doctype object JavaScript syntax: - myDocument.doctype HTML syntax: <!DOCTYPE aDocumentDescription> Argument list: aDocumentDescription A reference to a DTD for this document The <!DOCTYPE> tag at the top of the document is instantiated into a Doctype object and a reference to it is stored here. This tag describes a DTD statement that identifies the type of document. Here is a properly formed DTD statement: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 FINAL//EN"> This is represented by an object whose type is a single exclamation mark. As this tag should be on the first line of a document, the object will be at index 0 in the document.all[] array. Support for this is still somewhat patchy as of Netscape 6.0 and MSIE 5.5. Netscape 6.0 returns a DocType object (note the class name capitalization) but its string value is not defined. MSIE returns an undefined value. D – Document.documentElement (Property) 527 Warnings: ❑ There is apparently no access to this value in Netscape and MSIE only provides limited access. See also: ! object, !.tabIndex, Doctype object, Document object, Element object Property attributes: ReadOnly Document.documentElement (Property) An HTML element that represents the document. Availability: DOM level – 1 JavaScript – 1.5 JScript – 5.0 Internet Explorer – 5.0 Netscape – 6.0 Property/method value type: Element object JavaScript syntax: - myDocument.documentElement HTML syntax: <HTML> This property contains a reference to an Element object that corresponds to the <HTML> tag at the top of the document. Warnings: ❑ Traversing this object with a for( in ) loop in MSIE 5 may lead to a browser crash. This is unfortunately still true for version 5.5 of MSIE. See also: Document object, Element object, HTML object Property attributes: ReadOnly JavaScript Programmer's Reference 528 Document.domain (Property) A means of allowing web servers that trust one another to allow normally insecure access from one another's documents. Availability: DOM level – 1 JavaScript – 1.1 JScript – 3.0 Internet Explorer – 4.0 Netscape – 3.0 Opera – 3.0 Property/method value type: String primitive JavaScript syntax: - myDocument.domain This is part of the Netscape security model that allows unsigned scripts to communicate with one another as long as they belong to the same domain. Normally, documents may not always be able to communicate with one another because they come from different servers. This can be alleviated by specifying a domain that is shared by several servers. The initial value of this property is the complete host name of the server that provided the document when it was loaded. A script is able to set a domain value that is a suffix of the existing domain. So, aaa.bbb.ccc.com can become bbb.ccc.com but cannot become another.domain.com which allows you to serve documents from several hosts in the same domain but not access content served by other domains. Once any two documents have the same domain setting, they can exchange property values with one another even though they may have originated on different hosts. Global Function call Function call Function call Function call Function call Function call D – Document.elementFromPoint() (Method) 529 Warnings: ❑ This is not supported on the WebTV platform. See also: Document object, JellyScript, Security policy Property attributes: ReadOnly Document.elementFromPoint() (Method) Determines which element is under a particular x, y location. Availability: JScript – 3.0 Internet Explorer – 4.0 Property/method value type: Object object JavaScript syntax: IE myDocument.elementFromPoint(xCoordinate, yCoordinate) xCoordinate The X-coordinate value Argument list: yCoordinate The Y-coordinate value The result of this method will be a reference to the Element object under the x,y point. The document is inspected and the browser works out the topmost Element object at the indicated x,y location. That Element object is then returned as the result. This is very much like executing a mouse click at a location in the document window, and then extracting the target Element object from the event object. However this is far simpler. See also: Document object Document.embeds[] (Collection) An array of all the <EMBED> tag objects within the document. Availability: JavaScript – 1.1 JScript – 3.0 Internet Explorer – 4.0 Netscape – 3.0 Opera – 3.0 Property/method value type: EmbedArray object JavaScript syntax: - myDocument.embeds HTML syntax: <EMBED> JavaScript Programmer's Reference 530 Each <EMBED> tag is represented here by an object. The embeds are encapsulated in the same JavaObject objects as are used for the Java applets. Every embedded plugin will respond to different suites of property and method messages although there may be some similarities between some plugins that serve the same purpose. Warnings: ❑ Be aware that if you are not using some NAME or ID binding to the <EMBED> tags, you may get unexpected results if new embeds are added and you are accessing elements of this array using numeric index values. ❑ In Netscape, your JavaScript code interacts with them courtesy of LiveConnect in a very similar way. MSIE interacts with the embeds by means of ActiveX. This can lead to some differences in the way the plugins are supported and the things they can do in each browser environment. ❑ In MSIE on the Windows platform, plugins are often recommended for use with the <OBJECT> tag rather than the <EMBED> tag. This can lead to portability issues in your scripts and web pages. ❑ In MSIE version 4, this returns a Collection object instead of an EmbedArray object. MSIE 5 is more consistent with Netscape . ❑ Netscape and MSIE encapsulate plugin/embedded objects in a different way. In MSIE they are objects of the EMBED class. In Netscape they are objects commonly referred to as belonging to the Plugin class although they are really implemented as JavaObject objects. In MSIE, this is an ActiveX object. ❑ There is additional confusion in that there is a plugins[] array that belongs to the document and another that belongs to the navigator object. They both contain collections of objects but of different types. This is further confused by the fact that the document.plugins[] array is another name for the document.embeds[] array. ❑ Because of this confusing situation, the best recommendation is that we refer to document.embeds[] and navigator.plugins[] and quietly ignore the document.plugins[] array. Furthermore we shall refer to Plugin objects as being something the browser can use to play embedded content and Embed objects will be an instance of a plugin that is alive and running in a document. See also: <EMBED>, Document object, Document.applets[], Document.plugins[], Embed object, EmbedArray object, JavaObject object, LiveConnect Property attributes: ReadOnly Document.execCommand() (Method) Part of an MSIE special document command handling mechanism. A method for executing commands. Availability: JScript – 3.0 Internet Explorer – 4.0 Property/method value type: Boolean primitive [...]... Document.URL property Availability: DOM level – 1 JavaScript – 1.0 JScript – 1.0 Internet Explorer – 3. 02 Netscape – 2.0 Opera – 3. 0 Deprecated Property/method value type: Location object JavaScript syntax: - myDocument.location 547 JavaScript Programmer's Reference This is deprecated now in favor of using the Document.URL property to access a Url object In version 1.0 of JavaScript this was a simple string primitive... Window.frame Property attributes: ReadOnly 549 JavaScript Programmer's Reference Document.plugins[] (Collection) Another (confusing) name for the document.embeds property and NOT the navigator.plugins property Availability: JavaScript – 1.1 JScript – 3. 0 Internet Explorer – 4.0 Netscape – 3. 0 Opera – 3. 0 Deprecated Property/method value type: EmbedArray object JavaScript syntax: - myDocument.plugins Each... FileUpload.select(), TextRange.execCommand() Document.expando (Property) A means of locking objects to prevent new properties being added Availability: JScript – 3. 0 Internet Explorer – 4.0 533 JavaScript Programmer's Reference Property/method value type: Boolean primitive JavaScript syntax: IE myDocument.expando IE myDocument.expando = aSwitch aSwitch A boolean value to turn this feature on or off Argument list: When... visited Availability: DOM level – 0 JavaScript – 1.0 JScript – 1.0 Internet Explorer – 3. 02 Netscape – 2.0 Opera – 3. 0 Deprecated Property/method value type: Color value JavaScript syntax: - myDocument.linkColor - myDocument.linkColor = aColorValue HTML syntax: Argument list: aColorValue A hex color value or color name 545 JavaScript Programmer's Reference This value controls the... This is only supported by the 32 bit Windows version of MSIE 5 53 JavaScript Programmer's Reference See also: Document object, Document.execCommand(), TextRange.queryCommandSupported() Document.queryCommandText() (Method) Part of an MSIE special document command handling mechanism Availability: JScript – 3. 0 Internet Explorer – 4.0 Property/method value type: String primitive JavaScript syntax: IE Argument... portable script code See also: Document.lastModified, IMG.fileModifiedDate 535 JavaScript Programmer's Reference Property attributes: ReadOnly Document.fileSize (Property) The size in bytes of the file that was received by the browser Availability: JScript – 3. 0 Internet Explorer – 4.0 Property/method value type: Number primitive JavaScript syntax: IE myDocument.fileSize This is the exact length of the... list of all the forms in the document Availability: DOM level – 1 JavaScript – 1.0 JScript – 3. 0 Internet Explorer – 4.0 Netscape – 2.0 Opera – 3. 0 Property/method value type: FormArray object JavaScript syntax: - HTML syntax: myDocument.forms Every element in the document corresponds to an object in the forms[] array 536 D – Document.frames[] (Collection) Warnings: ❑ Be aware that if... contains references to all the child elements having the specified tag name Availability: DOM level – 1 JavaScript – 1.5 JScript – 5.0 Internet Explorer – 5.0 Netscape – 6.0 Property/method value type: NodeList object JavaScript syntax: - Argument list: aTagName See also: Element.getElementsByTagName(), NodeList object myDocument.getElementsByTagName(aTagName) The name of an HTML tag 539 JavaScript. .. Document.images[] (Collection) An array containing a list of all the images in the document Availability: DOM level – 1 JavaScript – 1.1 JScript – 3. 0 Internet Explorer – 4.0 Netscape – 3. 0 Opera – 3. 0 Property/method value type: ImageArray object 542 D – Document.implementation (Property) JavaScript syntax: - HTML syntax: myDocument.images Every image in the document corresponds to an element in... See also: Document object Document.fgColor (Property) The foreground color for text in the current document Availability: DOM level – 0 JavaScript – 1.0 JScript – 1.0 Internet Explorer – 3. 02 Netscape – 2.0 Opera – 3. 0 Deprecated Property/method value type: Color value JavaScript syntax: - myDocument.fgColor - myDocument.fgColor = aColorValue HTML syntax: Argument list: aColorValue . 1 JavaScript – 1.5 Netscape – 6.0 Property/method value type: EntityReference object JavaScript syntax: N myDocument.createEntityReference(aName) Argument list: aName The name of the entity reference. documents. Availability: DOM level – 1 JavaScript – 1.1 JScript – 3. 0 Internet Explorer – 4.0 Netscape – 3. 0 Opera – 3. 0 Property/method value type: String primitive JavaScript syntax: - myDocument.domain This. within the document. Availability: JavaScript – 1.1 JScript – 3. 0 Internet Explorer – 4.0 Netscape – 3. 0 Opera – 3. 0 Property/method value type: EmbedArray object JavaScript syntax: - myDocument.embeds HTML

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