In all the examples that follow, the variable theDOM is understood to have been established early
on, like this:
var theDOM = dreamweaver.getDocumentDOM(???document???);
The dom.getSelection() function
How a behavior performs is quite often dictated by what tag the user selects prior to attaching the behavior.
The getSelection() function is the first step toward getting all the information necessary to control
the behavior based on a user selection. I emphasize first step because this function returns the selection
in the form of byte offsets in memory. A byte offset is a number that points to a memory address. In the
case of the getSelection() function, the two byte offsets that are returned mark the beginning and end
of the selection in memory. For example, you open a new page in Dreamweaver, type in a phrase such as
The Key Points, and then select the first word, The. If you used the getSelection function like this:
var selArray = theDOM.getSelection();
alert(selArray);
the alert box would return 161,164, which denotes the beginning byte (161) and the ending byte (164)
offset of the selected word, The. If your beginning and ending byte offsets are the same (as in 164,164),
nothing is selected. This fact comes in handy when you want to make sure that the user has selected something
before proceeding.
Pages:
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927