Adobe GoLive CS2 Programmer's Manual page 103

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
<body><h1>Title</h1><p>abcd xyz</p></body>
Range 1 is a complex selection that spans two text elements, with part of each in the selection, while
Range 2 is a full selection of one markup element.
In Range 1, the startContainer and endContainer properties identify the elements that the
range spans. Because both <h1> and <p> are text elements, the offsets are the respective character
offsets of the start and end positions within those two elements:
startContainer
h1
In Range 2, the startContainer and endContainer properties both identify the single containing
element—in this case, the <body> element. Because it is not a text element, the offsets are element
offsets to the selected element:
startContainer
body
You can retrieve a range object from the range property of the selection object. For each user
selection, GoLive creates a corresponding range object. The initial range is the same as that of the current
selection. However, if you retrieve the range object, then change the selection, that range object still has
the old selection's range, while the document.selection.range property holds a new range object.
For example:
var range_a = document.selection.range;
Now change the document selection and create a new variable:
var range_b = document.selection.range.
The range objects range_a and range_b contain the ranges of the previous and current selections.
Now change the document selection back to the initial range and create a third variable:
var range_c = document.selection.range
Adobe GoLive CS2 SDK
Range 1
Range 2
body
h1
"abcd xyz"
"Title"
Range 1
startOffset
2
(2nd character in
)
<h1>
startOffset
1
(1st subelement in
<body>
p
Range 2
endContainer
endOffset
p
2
(2nd character in
endContainer
endOffset
body
2
)
(2st subelement in
Editing Documents Programmatically
)
<p>
)
<body>
103

Advertisement

Table of Contents
loading

Table of Contents