< Day Day Up > |
File manipulation functions handle creating, opening, and saving documents (including XML and XHTML), converting existing HTML documents into XHTML, and exporting CSS to external files. These functions accomplish such tasks as browsing for files or folders, creating files based on templates, closing documents, and getting information about recently opened files. dom.cleanupXHTML()Availability Dreamweaver MX. Description This function is similar to the convertToXHTML() function, but it cleans up an existing XHTML document. This function can run on a selection within the document. You can run the cleanupXHTML() function to clean up the syntax in an entire XHTML document or in the current selection of a document. Arguments bWholeDoc
Returns An array of six integers that quantify the number of the following elements:
dom.convertToXHTML()Availability Dreamweaver MX. Description Parses the HTML into a DOM tree, inserts missing items that are required for XHTML, cleans up the tree, and then writes the tree as clean XHTML. The missing directives, declarations, elements, and attributes that the convertToXHTML() function adds to the DOM tree, as necessary, include the following items:
During the conversion, the dom.convertToXHTML() function converts pure HTML tags and attributes to lowercase, writes HTML tags and attributes with correct XHTML syntax, and adds missing HTML attributes where it can. This function treats third-party tags and attributes according to the settings in the Preferences dialog box. If the document is a template, the dom.convertToXHTML() function alerts the user but does not perform the conversion. Arguments None. Returns An array of six integers that quantify the following items:
Example In normal use, an extension first calls the dreamweaver.openDocument() or dreamweaver.getDocumentDOM() functions to get a reference to the document. The extension then calls the dom.getIsXHTMLDocument() function to determine whether the document is already in XHTML form. If it is not, the extension calls the dom.convertToXHTML() function to convert the document into XHTML. Then the extension calls the dreamweaver.saveDocument() function to save the converted file with a new filename. dom.getIsXHTMLDocument()Availability Dreamweaver MX. Description Checks a document (specifically, the <!DOCTYPE> declaration) to see whether it is XHTML. Arguments None. Returns A true value if the document is XHTML; false otherwise. dreamweaver.browseForFileURL()Availability Dreamweaver 1, enhanced in 2, 3, and 4. Description Opens the specified type of dialog box with the specified label in the title bar. Arguments openSelectOrSave, {titleBarLabel}, {bShowPreviewPane}, {bSupressSiteRootWarnings}, {arrayOfExtensions}
Returns A string that contains the name of the file, which is expressed as a file:// URL. dreamweaver.browseForFolderURL()Availability Dreamweaver 3. Description Opens the Choose Folder dialog box with the specified label in the title bar. Arguments {titleBarLabel}, {directoryToStartIn}
Returns A string that contains the name of the folder, which is expressed as a file:// URL. Example The following code returns the URL of a folder: return dreamweaver.browseForFolderURL('Select a Folder', dreamweaver.getSiteRoot()); dreamweaver.closeDocument()Availability Dreamweaver 2. Description Closes the specified document. Arguments documentObject
Returns Nothing. dreamweaver.createDocument()Availability Dreamweaver 2, enhanced in Dreamweaver 4. Description Depending on the argument that you pass to this function, it opens a new document either in the same window or in a new window. The new document becomes the active document. NOTE This function can be called only from the menus.xml file, a command, or the Property inspector file. If a behavior action or object tries to call this function, Dreamweaver displays an error message. Arguments {bOpenInSameWindow}, {type}
NOTE You can extend the MMDocumentTypes file by adding your own document types. For information on extending document types, see Extending Dreamweaver. Returns The document object for the newly created document. This is the same value that the dreamweaver.getDocumentDOM()function returns. dreamweaver.createXHTMLDocument()Availability Dreamweaver MX. Description Depending on the argument that you pass to this function, it opens a new XHTML document either in the same window or in a new window. The new document becomes the active document. It is similar to the dreamweaver.createDocument() function. When Dreamweaver creates a new XHTML document, it reads a file named default.xhtml, which is located in the Configuration/Templates folder, and, using the content of that file, creates an output file that contains the following skeleton declarations: <?xml version="1.0"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=" /> </head> <body bgcolor="#FFFFFF" text="#000000"> </body> </html> The default document type definition (DTD) declaration is XHTML 1.0 Transitional, rather than Strict. If the user adds a frameset to the document, Dreamweaver switches the DTD to XHTML 1.0 Frameset. Content-Type is text/html, and charset is intentionally left out of the default.xhtml file but is filled in before the user views the new document. The ?xml directive is not required if the document uses UTF-8 or UTF-16 character encoding; if it is present, it might be rendered by some older browsers. However, because this directive should be in an XHTML document, by default, Dreamweaver uses it (for both new and converted documents). Users can manually delete the directive. The ?xml directive includes the encoding attribute, which matches the charset in the Content-Type attribute. Arguments {bOpenInSameWindow}
Returns The document object for the newly created document, which is the same value that the dreamweaver.getDocumentDOM() function returns. dreamweaver.createXMLDocument()Availability Dreamweaver MX. Description Creates and opens a new XML file, which is empty except for the XML directive. Arguments None. Returns The DOM of the new XML file. Example The following example creates a new document, which is empty except for the XML directive: var theDOM = dreamweaver.createXMLDocument("document"); dreamweaver.exportCSS()Availability Dreamweaver 3. Description Opens the Export Styles as a CSS File dialog box. Arguments None. Returns Nothing. Enabler See "dreamweaver.canExportCSS()" on page 1070. dreamweaver.exportEditableRegionsAsXML() (deprecated)Availability Dreamweaver 3; deprecated in MX. Description This function opens the Export Editable Regions as XML dialog box. Arguments None. Returns Nothing. dreamweaver.exportTemplateDataAsXML()Availability Dreamweaver MX. Description Exports the current document to the specified file as XML. This function operates on the document that has focus, which must be a template. If you do not specify a filename argument, Dreamweaver MX opens a dialog box to request the export file string. Arguments {filePath}
Returns Nothing. Enabler See "dreamweaver.canExportTemplateDataAsXML()" on page 1071. Example if(dreamweaver.canExportTemplateDataAsXML()) { dreamweaver.exportTemplateDataAsXML("file:///c|/dw_temps/mytemplate.txt") } dreamweaver.getDocumentDOM()Availability Dreamweaver 2. Description Provides access to the objects tree for the specified document. After the tree of objects returns to the caller, the caller can edit the tree to change the contents of the document. Arguments {sourceDoc}
NOTE If the argument is "document", the calling function must be the applyBehavior(), deleteBehavior(), objectTag() function, or any function in a command or Property inspector file that can perform edits to the document. Returns The JavaScript document object at the root of the tree. Examples The following example uses the dreamweaver.getDocumentDOM() function to access the current document: var theDOM = dreamweaver.getDocumentDOM("document"); In the following example, the current document DOM identifies a selection and pastes it at the end of another document: var currentDOM = dreamweaver.getDocumentDOM('document'); currentDOM.setSelection(100,200); currentDOM.clipCopy(); var otherDOM = dreamweaver.openDocument(dreamweaver. getSiteRoot() + "html/foo.htm"); otherDOM.endOfDocument(); otherDOM.clipPaste(); NOTE The openDocument() argument is used because DOM methods normally operate only on open documents. Running a function on a document that isn't open causes a Dreamweaver error. The DOM methods that can operate only on the active document or on closed documents indicate this fact in their descriptions. dreamweaver.getNewDocumentDOM()Availability Dreamweaver MX; added documentType argument in Dreamweaver 8. Description Provides access to the editable tree for a new, empty document. This function works in the same way as the geTDocumetDOM() function, except that it points to a new document, not an existing one, and does not open the document. Arguments {documentType}
Returns A pointer to a new, empty document. Example The following code returns the DOM for a new, empty document: var theDOM = dreamweaver.getNewDocumentDOM(); dreamweaver.getRecentFileList()Availability Dreamweaver 3. Description Gets a list of all the files in the recent files list at the bottom of the File menu. Arguments None. Returns An array of strings that represent the paths of the most recently accessed files. Each path is expressed as a file:// URL. If there are no recent files, the function returns nothing. dreamweaver.importXMLIntoTemplate()Availability Dreamweaver 3. Description Imports an XML text file into the current template document. This function operates on the document that has focus, which must be a template. If you do not specify a filename argument, Dreamweaver opens a dialog box to request the import file string. Arguments {filePath}
Returns Nothing. dreamweaver.newDocument()Availability Dreamweaver MX. Description Opens a document in the current site and invokes the New Document dialog box. Arguments {bopenWithCurSiteAndShowDialog}
Returns Nothing. dreamweaver.newFromTemplate()Availability Dreamweaver 3. Description Creates a new document from the specified template. If no argument is supplied, the Select Template dialog box appears. Arguments {templateURL}, bMaintain
Returns Nothing. dreamweaver.openDocument()Availability Dreamweaver 2. Description Opens a document for editing in a new Dreamweaver window and gives it the focus. For a user, the effect is the same as selecting File > Open and selecting a file. If the specified file is already open, the window that contains the document comes to the front. The window that contains the specified file becomes the currently selected document. In Dreamweaver 2, if Check In/Check Out is enabled, the file is checked out before it opens. In Dreamweaver 3 and later, you must use dreamweaver.openDocumentFromSite() to get this behavior. NOTE This function will cause an error if called from Behavior action or object files. Arguments fileName
Returns The document object for the specified file, which is the same value that the dreamweaver.getDocumentDOM() function returns. dreamweaver.openDocumentFromSite()Availability Dreamweaver 3. Description Opens a document for editing in a new Dreamweaver window and gives it the focus. For a user, the effect is the same as double-clicking a file in the Site panel. If the specified file is already open, the window that contains the document comes to the front. The window that contains the specified file becomes the currently selected document. NOTE This function cannot be called from Behavior action or object files because it causes an error. Arguments fileName
Returns The document object for the specified file, which is the same value that the dreamweaver.getDocumentDOM() function returns. dreamweaver.openInFrame()Availability Dreamweaver 3. Description Opens the Open In Frame dialog box. When the user selects a document, it opens into the active frame. Arguments None. Returns Nothing. Enabler See "dreamweaver.canOpenInFrame()" on page 1072. dreamweaver.releaseDocument()Availability Dreamweaver 2. Description Explicitly releases a previously referenced document from memory. Documents that are referenced by the dreamweaver.getObjectTags(), dreamweaver.getObjectRefs(), dreamweaver.getDocumentPath(), or dreamweaver.getDocumentDOM() functions are automatically released when the script that contains the call finishes executing. If the script opens many documents, you must use this function to explicitly release documents before finishing the script to avoid running out of memory. NOTE This function is relevant only for documents that were referenced by a URL, are not currently open in a frame or document window, and are not extension files. Extension files are loaded into memory at startup and are not released until you quit Dreamweaver. Arguments documentObject
Returns Nothing. dreamweaver.revertDocument()Availability Dreamweaver 3. Description Reverts the specified document to the previously saved version. Arguments documentObject
Returns Nothing. Enabler See "dreamweaver.canRevertDocument()" on page 1074. dreamweaver.saveAll()Availability Dreamweaver 3. Description Saves all open documents, opening the Save As dialog box for any documents that have not been saved previously. Arguments None. Returns Nothing. Enabler See "dreamweaver.canSaveAll()" on page 1074. dreamweaver.saveDocument()Availability Dreamweaver 2. Description Saves the specified file on a local computer. NOTE In Dreamweaver 2, if the file is read-only, Dreamweaver tries to check it out. If the document is still read-only after this attempt, or if it cannot be created, an error message appears. Arguments documentObject, {fileURL}
Returns A Boolean value that indicates success (TRue) or failure (false). Enabler See "dreamweaver.canSaveDocument()" on page 1075. dreamweaver.saveDocumentAs()Availability Dreamweaver 3. Description Opens the Save As dialog box. Arguments documentObject
Returns Nothing. dreamweaver.saveDocumentAsTemplate()Availability Dreamweaver 3. Description Opens the Save As Template dialog box. Arguments documentObject, {fileName}
Returns Nothing. Enabler See "dreamweaver.canSaveDocumentAsTemplate()" on page 1075. dreamweaver.saveFrameset()Availability Dreamweaver 3. Description Saves the specified frameset or opens the Save As dialog box if the frameset has not previously been saved. Arguments documentObject
Returns Nothing. Enabler See "dreamweaver.canSaveFrameset()" on page 1076. dreamweaver.saveFramesetAs()Availability Dreamweaver 3. Description Opens the Save As dialog box for the frameset file that includes the specified DOM. Arguments documentObject
Returns Nothing. Enabler See "dreamweaver.canSaveFramesetAs()" on page 1076. |
< Day Day Up > |