< Day Day Up > |
Code view functions include operations that are related to editing document source code (and that have subsequent impact on the Design view). The functions in this section let you add navigational controls to Code views within a split document view or the Code inspector window. dom.formatRange()Availability Dreamweaver MX. Description Applies Dreamweaver automatic syntax formatting to a specified range of characters in the Code view, according to the settings in the Preferences > Code Format dialog box. Arguments startOffset, endOffset
Returns Nothing. dom.formatSelection()Availability Dreamweaver MX. Description Applies Dreamweaver automatic syntax formatting to the selected content (the same as selecting the Commands > Apply Source Formatting to Selection option) according to the settings in the Preferences > Code Format dialog box. Arguments None. Returns Nothing. dom.getShowNoscript()Availability Dreamweaver MX. Description Gets the current state of the noscript content option (from the View > Noscript Content menu option). On by default, the noscript tag identifies page script content that can be rendered, or not (by choice), in the browser. Arguments None. Returns A Boolean value: TRue if the noscript tag content is currently rendered; false otherwise. dom.getAutoValidationCount()Availability Dreamweaver MX 2004. Description Gets the number of errors, warnings, and information messages for the last auto-validation (also known as an inline validation) of the document. Currently only a target-browser check is performed during auto-validation (see "dom.runValidation()" on page 826). NOTE This function returns only the results that are currently in the results window for the document. If you want to make sure that the counts are up-to-date, you can call dom.runValidation() before calling this function. Arguments None. Returns An object with the following properties:
Example theDom = dw.getDocumentDOM(); theDom.runValidation(); theDom.getAutoValidationCount(); dom.isDesignViewUpdated()Availability Dreamweaver 4. Description Determines whether the Design view and Text view content is synchronized for those Dreamweaver operations that require a valid document state. Arguments None. Returns A Boolean value: true if the Design view (WYSIWYG) is synchronized with the text in the Text view; false otherwise. dom.isSelectionValid()Availability Dreamweaver 4. Description Determines whether a selection is valid, meaning it is currently synchronized with the Design view, or if it needs to be moved before an operation occurs. Arguments None. Returns A Boolean value: TRue if the current selection is in a valid piece of code; false if the document has not been synchronized, because the selection is not updated. dom.setShowNoscript()Availability Dreamweaver MX. Description Sets the noscript content option on or off (the same as selecting the View > Noscript Content option). On by default, the noscript tag identifies page script content that can be rendered, or not (by choice), in the browser. Arguments {bShowNoscript}
Returns Nothing. dom.source.arrowDown()Availability Dreamweaver 4. Description Moves the insertion point down the Code view document, line by line. If content is already selected, this function extends the selection line by line. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.arrowLeft()Availability Dreamweaver 4. Description Moves the insertion point to the left in the current line of the Code view. If content is already selected, this function extends the selection to the left. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.arrowRight()Availability Dreamweaver 4. Description Moves the insertion point to the right in the current line of the Code view. If content is already selected, this function extends the selection to the right. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.arrowUp()Availability Dreamweaver 4. Description Moves the insertion point up the Code view document, line by line. If content is already selected, this function extends the selection line by line. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.balanceBracesTextview()Availability Dreamweaver 4. Description This function is a Code view extension that enables parentheses balancing. You can call dom.source.balanceBracesTextview() to extend a currently highlighted selection or insertion point from the opening of the surrounding parenthetical statement to the end of the statement to balance the following characters: [], {} and (). Subsequent calls expand the selection through further levels of punctuation nesting. Arguments None. Returns Nothing. dom.source.endOfDocument()Availability Dreamweaver 4. Description Places the insertion point at the end of the current Code view document. If content is already selected, this function extends the selection to the end of the document. Arguments bShiftIsDown
Returns Nothing. dom.source.endOfLine()Availability Dreamweaver 4. Description Places the insertion point at the end of the current line. If content is already selected, this function extends the selection to the end of the current line. Arguments bShiftIsDown
Returns Nothing. dom.source.endPage()Availability Dreamweaver 4. Description Moves the insertion point to the end of the current page or to the end of the next page if the insertion point is already at the end of a page. If content is already selected, this function extends the selection page by page. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.getCurrentLines()Availability Dreamweaver 4. Description Returns the line numbers for the specified offset locations from the beginning of the document. Arguments None. Returns The line numbers for the current selection. dom.source.getSelection()Description Gets the selection in the current document, which is expressed as character offsets into the document's Code view. Arguments None. Returns A pair of integers that represent offsets from the beginning of the source document. The first integer is the opening of the selection; the second is the closing of the selection. If the two numbers are equal, the selection is an insertion point. If there is no selection in the source, both numbers are -1. dom.source.getLineFromOffset()Availability Dreamweaver MX. Description Takes an offset into the source document. Arguments None. Returns The associated line number, or -1 if the offset is negative or past the end of the file. dom.source.getText()Availability Dreamweaver 4. Description Returns the text string in the source between the designated offsets. Arguments startOffset, endOffset
Returns A string that represents the text in the source code between the offsets start and end. dom.source.getValidationErrorsForOffset()Availability Dreamweaver MX 2004. Description Returns a list of validation errors at the specified offset, or it searches from the offset for the next error. If none are found the function, it returns null. Arguments offset, {searchDirection}
Returns An array of objects or the value null. Each object in the array has the following properties:
Example The following example calls getValidationErrorsForOffset() to check for any errors at the offset of the current selection. If the function returns an error, the code calls the alert() function to display the error message to the user. var offset = dw.getDocumentDOM().source.getSelection()[0]; var errors = dw.getDocumentDOM().source.getValidationErrorsForOffset(offset); if ( errors && errors.length > 0 ) alert( errors[0].message ); dom.source.indentTextview()Availability Dreamweaver 4. Description Moves selected Code view text one tab stop to the right. Arguments None. Returns Nothing. dom.source.insert()Availability Dreamweaver 4. Description Inserts the specified string into the source code at the specified offset from the beginning of the source file. If the offset is not greater than or equal to zero, the insertion fails and the function returns false. Arguments offset, string
Returns A Boolean value: true if successful; false otherwise. dom.source.nextWord()Availability Dreamweaver 4. Description Moves the insertion point to the beginning of the next word (or words, if specified) in the Code view. If content is already selected, this function extends the selection to the right. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.outdentTextview()Availability Dreamweaver 4. Description Moves selected Code view text one tab stop to the left. Arguments None. Returns Nothing. dom.source.pageDown()Availability Dreamweaver 4. Description Moves the insertion point down the Code view document, page by page. If content is already selected, this function extends the selection page by page. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.pageUp()Availability Dreamweaver 4. Description Moves the insertion point up the Code view document, page by page. If content is already selected, this function extends the selection page by page. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.previousWord()Availability Dreamweaver 4. Description Moves the insertion point to the beginning of the previous word (or words, if specified) in Code view. If content is already selected, this function extends the selection to the left. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.replaceRange()Availability Dreamweaver 4. Description Replaces the range of source text between startOffset and endOffset with string. If startOffset is greater than endOffset or if either offset is not a positive integer, it does nothing and returns false. If endOffset is greater than the number of characters in the file, it replaces the range between startOffset and the end of the file. If both startOffset and endOffset are greater than the number of characters in the file, it inserts the text at the end of the file. Arguments startOffset, endOffset, string
Returns A Boolean value: TRue if successful; false otherwise. dom.source.scrollEndFile()Availability Dreamweaver 4. Description Scrolls the Code view to the bottom of the document file without moving the insertion point. Arguments None. Returns Nothing. dom.source.scrollLineDown()Availability Dreamweaver 4. Description Scrolls the Code view down line by line without moving the insertion point. Arguments nTimes
Returns Nothing. dom.source.scrollLineUp()Availability Dreamweaver 4. Description Scrolls the Code view up line by line without moving the insertion point. Arguments nTimes
Returns Nothing. dom.source.scrollPageDown()Availability Dreamweaver 4. Description Scrolls the Code view down page by page without moving the insertion point. Arguments nTimes
Returns Nothing. dom.source.scrollPageUp()Availability Dreamweaver 4. Description Scrolls the Code view up page by page without moving the insertion point. Arguments nTimes
Returns Nothing. dom.source.scrollTopFile()Availability Dreamweaver 4. Description Scrolls the Code view to the top of the document file without moving the insertion point. Arguments None. Returns Nothing. dom.source.selectParentTag()Availability Dreamweaver 4. Description This function is a Code view extension that enables tag balancing. You can call dom.source.selectParentTag() to extend a currently highlighted selection or insertion point from the surrounding open tag to the closing tag. Subsequent calls extend the selection to additional surrounding tags until there are no more enclosing tags. Arguments None. Returns Nothing. dom.source.setCurrentLine()Availability Dreamweaver 4. Description Puts the insertion point at the beginning of the specified line. If the lineNumber argument is not a positive integer, the function does nothing and returns false. It puts the insertion point at the beginning of the last line if lineNumber is larger than the number of lines in the source. Arguments lineNumber
Returns A Boolean value: true if successful; false otherwise. dom.source.startOfDocument()Availability Dreamweaver 4. Description Places the insertion point at the beginning of the Code view document. If content is already selected, this function extends the selection to the beginning of the document. Arguments bShiftIsDown
Returns Nothing. dom.source.startOfLine()Availability Dreamweaver 4. Description Places the insertion point at the beginning of the current line. If content is already selected, this function extends the selection to the beginning of the current line. Arguments bShiftIsDown
Returns Nothing. dom.source.topPage()Availability Dreamweaver 4. Description Moves the insertion point to the top of the current page or to the top of the previous page if the insertion point is already at the top of a page. If content is already selected, this function extends the selection page by page. Arguments {nTimes}, {bShiftIsDown}
Returns Nothing. dom.source.wrapSelection()Availability Dreamweaver 4. Description Inserts the text of startTag before the current selection and the text of endTag after the current selection. The function then selects the entire range between, and including, the inserted tags. If the current selection was an insertion point, then the function places the insertion point between the startTag and endTag. (startTag and endTag don't have to be tags; they can be any arbitrary text.) Arguments startTag, endTag
Returns Nothing. dom.synchronizeDocument()Availability Dreamweaver 4. Description Synchronizes the Design and Code views. Arguments None. Returns Nothing. |
< Day Day Up > |