The Selection interface supports the following properties.
CanChange(strElementName) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the container of the selection can be changed to the specified strElementName. |
Usage | |
JScript | Selection_object.CanChange("strElementName"); |
VBScript | Selection_object.CanChange("strElementName") |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.CanChange("PRE")) { Selection.ContainerName="PRE"; } else { Application.Alert("Can't change to PRE!"); } |
CanInsert(strElementName) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the element strElementName can replace the selection. See also CanSurround. |
Usage | |
JScript | Selection_object.CanInsert("strElementName"); |
VBScript | Selection_object.CanInsert("strElementName") |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.CanInsert("P")) { Selection.InsertElement("P"); } else { Application.Alert("Can't insert P here!"); } |
CanInsertText | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether text can be inserted at the selection. |
Usage | |
JScript | Selection_object.CanInsertText; |
VBScript | Selection_object.CanInsertText |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.CanInsertText) { Selection.Text="OK to insert text here!"; } else { Application.Alert("Can't insert text here!"); } |
CanSurround(strElementName) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the selection can be surrounded by the specified strElementName. |
Usage | |
JScript | Selection_object.CanSurround("strElementName"); |
VBScript | Selection_object.CanSurround("strElementName") |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.CanSurround("P")) { Selection.Surround("P"); } else { Application.Alert("Can't surround with P!"); } |
CanPaste(strText, [boolInterpret=false]) | |
Access | Read-only |
Type | Boolean |
Description |
If boolInterpret is false, CanPaste indicates whether the specified strText can be pasted over the selection using a basic paste, as done with Selection.PasteString (that is, if the paste would not be valid, HoTMetaL PRO will not attempt to rearrange the markup in order to make it valid; the paste will simply be disallowed). The string can contain markup, which will be parsed in order to determine whether it can be pasted. If boolInterpret is true, CanPaste tests whether strText can be pasted by Selection.PasteStringWithInterpret, which will paste strText as an HTML table if it is tab-formatted as a table. |
Usage | |
JScript | Selection_object.CanPaste("String"); |
VBScript | Selection_object.CanPaste("String") |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.CanPaste("<P></P>")) { Selection.PasteString("<P></P"); } else { Application.Alert("Can't paste '<P></P'"); } |
ContainerAttribute(strAttrName) | |
Access | Read/write |
Type | String |
Description | Sets or returns the value of the strAttrName attribute for the selection's container (if the container is an element). |
Usage | |
JScript | Selection_object.ContainerAttribute("strAttrName"); |
VBScript | Selection_object.ContainerAttribute("strAttrName") |
Example |
// SoftQuad Script Language JSCRIPT: // This returns the value of the "Id" attribute for the // selection's container Application.Alert(Selection.ContainerAttribute("Id")); // This sets the value of the "Id" attribute for the // selection's container Selection.ContainerAttribute("Id")="Newvalue"; Application.Alert(Selection.ContainerAttribute("Id")); |
ContainerName | |
Access | Read/write |
Type | String |
Description |
Sets or returns the name of the container that contains the selection. If the container is
an element, the element name is returned. Other container names are:
|
Usage | |
JScript |
vbl = Selection_object.ContainerName; Selection_object.ContainerName = strName; |
VBScript |
vbl = Selection_object.ContainerName Selection_object.ContainerName = strName |
Example |
// SoftQuad Script Language JSCRIPT: // display container name Application.Alert(Selection.ContainerName); // change the container to PRE Selection.ContainerName="PRE"; |
ContainerNode | |
Access | Read-only |
Type | DOMNode |
Description | Returns the DOMNode corresponding to the selection's container. |
Usage | |
JScript | Selection_object.ContainerNode; |
VBScript | Selection_object.ContainerNode |
Example |
// SoftQuad Script Language JSCRIPT: Application.Alert(Selection.ContainerNode.nodeName); |
Contains(Range, [boolIncludesAsEdge=false]) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the selection completely contains the specified Range. If the optional argument boolIncludesAsEdge is true, then Contains will return true if the Range is an insertion point at the left or right edge of the selection. |
Usage | |
JScript | Selection_object.Contains(Range_object, [boolIncludesAsEdge]); |
VBScript | Selection_object.Contains(Range_object, [boolIncludesAsEdge]) |
Document | |
Access | Read-only |
Type | Document |
Description | Returns the Document object that contains the selection. |
Usage | |
JScript | Selection_object.Document; |
VBScript | Selection_object.Document |
Example |
// SoftQuad Script Language JSCRIPT: var curDoc=Selection.Document; Application.Alert(curDoc.FullName); |
ElementAttribute(strAttrName, strElementName, [longSkipNum=0]) (Extension to DOM) | |
Access | Read/write |
Type | String |
Description | Sets or returns value of the attribute strAttrName from the specified element strElementName (if it is the selection's container or other ancestor). If longSkipNum is specified, that number of elements of the same name will be skipped (useful for nested tables). |
Usage | |
JScript | Selection_object.ElementAttribute("strAttrName", "strElementName", [longSkipNum=0]); |
VBScript | Selection_object.ElementAttribute("strAttrname", "strElementName", [longSkipNum=0]) |
Example |
// SoftQuad Script Language JSCRIPT: // Return the value of the WIDTH attribute // from the TABLE element var attr = Selection.ElementAttribute("WIDTH", "TABLE"); |
ElementName(longLevels) | |
Access | Read-only |
Type | String |
Description | Returns the name of the ancestor element of the current selection, longLevels levels up. A value of 0 returns the name of selection's container. |
Usage | |
JScript | Selection_object.ElementName(longLevels); |
VBScript | Selection_object.ElementName(longLevels) |
Example |
// SoftQuad Script Language JSCRIPT: // return the name of the selection container's // parent element Application.Alert(Selection.ElementName(1)); |
Find | |
Access | Read-only |
Type | Find |
Description | Provides access to the Find object. This will enable you to perform find and replace operations in the document. |
Usage | |
JScript | Selection_object.Find; |
VBScript | Selection_object.Find |
Example |
// SoftQuad Script Language JSCRIPT: // will locate and select "some text" Selection.Find.Execute("some text"); |
Font | |
Access | read |
Type | Font |
Description | Allows access to the Font object of the selected text. This property applies only to HTML documents. |
Usage | |
JScript | Selection_object.Font; |
VBScript | Selection_object.Font |
Example |
// SoftQuad Script Language JSCRIPT: Application.Alert(Selection.Font.Size); |
hasAttribute(strAttrName) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether an attribute strAttrName has been declared for the selection's container (the attribute may or may not have a value). |
Usage | |
JScript | Selection_object.hasAttribute("strAttrName"); |
VBScript | Selection_object.hasAttribute("strAttrName") |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.hasAttribute("ID")) { Application.Alert("Identifier element."); } |
HorizontalAlignment | |
Access | Read/write |
Type | Integer |
Description |
Gets or sets the horizontal alignment of the element containing the selection. The allowed
values are:
|
Usage | |
JScript |
vbl = Selection_object.HorizontalAlignment; Selection_object.HorizontalAlignment = intAlign; |
VBScript |
vbl = Selection_object.HorizontalAlignment Selection_object.HorizontalAlignment = intAlign |
Example |
// SoftQuad Script Language JSCRIPT: Selection.HorizontalAlignment = 1; |
IsAdjacent(Range) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the selection is adjacent to the specified Range. |
Usage | |
JScript | Selection_object.IsAdjacent(Range_object); |
VBScript | Selection_object.IsAdjacent(Range_object) |
IsEqual(Range) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the selection is equal to the specified Range. |
Usage | |
JScript | Selection_object.IsEqual(Range_object); |
VBScript | Selection_object.IsEqual(Range_object) |
IsGreaterThan(Range, [boolOrEqual=false]) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the left end of the selection is greater than (that is, is to the right of) the left end of the specified Range. If the optional argument boolOrEqual is true, then IsGreaterThan will return true if the left end of the selection is equal to the left edge of the Range. |
Usage | |
JScript | Selection_object.IsGreaterThan(Range_object, [boolOrEqual]); |
VBScript | Selection_object.IsGreaterThan(Range_object, [boolOrEqual]) |
IsInsertionPoint | |
Access | Read-only |
Type | Boolean |
Description | True if the selection is an insertion point (that is, it has no content). |
Usage | |
JScript | Selection_object.IsInsertionPoint; |
VBScript | Selection_object.IsInsertionPoint |
Example |
// SoftQuad Script Language JSCRIPT: Application.Alert(Selection.IsInsertionPoint); |
IsLessThan(Range, [boolOrEqual=false]) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the left end of the selection is less than (that is, to the left of) the left end of the specified Range. If the optional argument boolOrEqual is true, then IsLessThan will return true if the left end of the selection is equal to the left edge of the Range. |
Usage | |
JScript | Selection_object.IsLessThan(Range_object, [boolOrEqual]); |
VBScript | Selection_object.IsLessThan(Range_object, [boolOrEqual]) |
IsParentElement(strElementName) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the element strElementName is an ancestor of the selection, at any level. |
Usage | |
JScript | Selection_object.IsParentElement("strElementName"); |
VBScript | Selection_object.IsParentElement("strElementName") |
Example |
// SoftQuad Script Language JSCRIPT: var isparent; isparent = Selection.IsParentElement("PRE"); |
IsValid | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the selection is valid. Displays no messages to the user. Returns true if the selection is an insertion point. See also Selection.Validate, Document.Validate and Document.IsValid. |
Usage | |
JScript | Selection_object.IsValid; |
VBScript | Selection_object.IsValid |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.IsValid) { Application.Alert("Selection is valid!"); } else { Application.Alert("Selection is not valid!"); } |
Overlaps(Range) | |
Access | Read-only |
Type | Boolean |
Description | Indicates whether the selection overlaps the specified Range. |
Usage | |
JScript | Selection_object.Overlaps(Range_object); |
VBScript | Selection_object.Overlaps(Range_object) |
ReadOnly | |
Access | Read-only |
Type | Boolean |
Description | Returns true if the selection's container or one of its ancestors is read-only. |
Usage | |
JScript | Selection_object.ReadOnly; |
VBScript | Selection_object.ReadOnly |
ReadOnlyContainer | |
Access | Read/write |
Type | Boolean |
Description | Returns or sets the selection's container's read-only flag. |
Usage | |
JScript | Selection_object.ReadOnlyContainer; |
VBScript | Selection_object.ReadOnlyContainer |
Example |
// SoftQuad Script Language JSCRIPT: if (Selection.ContainerAttribute("Status")=="RO") Selection.ReadOnlyContainer = true; |
Style | |
Access | Read/write |
Type | String |
Description | Returns or sets the style element for the selection. |
Usage | |
JScript | Selection_object.Style; |
VBScript | Selection_object.Style |
Example |
// SoftQuad Script Language JSCRIPT: // display the style of the selection Application.Alert(Selection.Style); |
Text | |
Access | Read/write |
Type | String |
Description | Provides access to the text in the document's selection. If the selection contains any tag icons, they are returned as text. Assigning a string to Selection_object.Text replaces the selection, if the rules allow it. |
Usage | |
JScript |
vbl = Selection_object.Text; Selection_object.Text = strText; |
VBScript |
vbl = Selection_object.Text Selection_object.Text = strText |
Example |
// SoftQuad Script Language JSCRIPT: // grab current selected text Application.Alert(Selection.Text); // replace selected text with "new text" Selection.Text = "new text"; |
Copyright © SoftQuad Software Inc. 1999