Hallo,
eine HTML-Datei ist durch das document-Objekt vertreten.
Aber das Textrange-Objekt enthält die Text-Daten.
Daten können auch als JS-Datei per Script in das Dokument eingebunden werden, wenn JavaScript benutzt wird.
Die Eigenschaften .innerHTML und .innerText liefern auch Daten
(innerHTML inklusive HTML-Code wie Tags). Document-Objekt hat die natürlich nicht.
================================================================
Nachfolgend Angaben für HTML-DOM des Internet Explorers.
Gruss Tom
TextRange Object
Textrange liest den quelltext des HTML-Dokumentes aus
per style.visibility='hidden' lässt sich kein Objekt mit Text z.B. Textarea ausblenden
--------------------------------------------------------------------------------
Represents text in an HTML element.
Members Table
The following table lists the members exposed by the TextRange object. Click a tab on the left to choose the type of member you want to view.
Attributes/Properties
Show:
Attributes/Properties
Methods
Property Description
boundingHeight Retrieves the height of the rectangle that bounds the TextRange object.
boundingLeft Retrieves the distance between the left edge of the rectangle that bounds the TextRange object and the left side of the object that contains the TextRange.
boundingTop Retrieves the distance between the top edge of the rectangle that bounds the TextRange object and the top side of the object that contains the TextRange.
boundingWidth Retrieves the width of the rectangle that bounds the TextRange object.
htmlText Retrieves the HTML source as a valid HTML fragment.
offsetLeft Retrieves the calculated left position of the object relative to the layout or coordinate parent, as specified by the offsetParent property.
offsetTop Retrieves the calculated top position of the object relative to the layout or coordinate parent, as specified by the offsetParent property.
text Sets or retrieves the text contained within the range.
Achtung: Es wird der Textrange komplett ausgelesen, so wie er aktuell ist, und dann .text zugewiesen
.text muss also NICHT den Stand haben wie zum Zeitpunkt createTextRange() !!!
createTextRange() instanziert NUR das Textrange-Objekt und belegt nicht .text statisch !!!
Attributes/Properties
Methods
Method Description
collapse Moves the insertion point to the beginning or end of the current range.
compareEndPoints Compares an end point of a TextRange object with an end point of another range.
duplicate Returns a duplicate of the TextRange.
execCommand Executes a command on the current document, current selection, or the given range.
expand Expands the range so that partial units are completely contained.
findText Searches for text in the document and positions the start and end points of the range to encompass the search string.
getBookmark Retrieves a bookmark (opaque string) that can be used with moveToBookmark to return to the same range.
getBoundingClientRect Retrieves an object that specifies the bounds of a collection of TextRectangle objects.
getClientRects Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client. Each rectangle describes a single line.
inRange Returns a value indicating whether one range is contained within another.
isEqual Returns a value indicating whether the specified range is equal to the current range.
move Collapses the given text range and moves the empty range by the given number of units.
moveEnd Changes the end position of the range.
moveStart Changes the start position of the range.
moveToBookmark Moves to a bookmark.
moveToElementText Moves the text range so that the start and end positions of the range encompass the text in the given element.
moveToPoint Moves the start and end positions of the text range to the given point.
parentElement Retrieves the parent element for the given text range.
pasteHTML Pastes HTML text into the given text range, replacing any previous text and HTML elements in the range.
queryCommandEnabled Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document.
queryCommandIndeterm Returns a Boolean value that indicates whether the specified command is in the indeterminate state.
queryCommandState Returns a Boolean value that indicates the current state of the command.
queryCommandSupported Returns a Boolean value that indicates whether the current command is supported on the current range.
queryCommandValue Returns the current value of the document, range, or current selection for the given command.
scrollIntoView Causes the object to scroll into view, aligning it either at the top or bottom of the window.
select Makes the selection equal to the current object.
setEndPoint Sets the endpoint of one range based on the endpoint of another range.
Remarks
Use this object to retrieve and modify text in an element, to locate specific strings in the text, and to carry out commands that affect the appearance of the text.
To retrieve a text range object, apply the createTextRange method to a body, button, or textArea element or an input element that has TYPE text.
Modify the extent of the text range by moving its start and end positions with methods such as move, moveToElementText, and findText. Within the text range, you can retrieve and modify plain text or HTML text. These forms of text are identical except that HTML text includes HTML tags, and plain text does not.
This object is available in script as of Microsoft Internet Explorer 4.0.
Example
This example changes the text of a button element to "Clicked" through the TextRange object.
<SCRIPT LANGUAGE="JScript">
var b = document.all.tags("BUTTON");
if (b!=null) {
var r = b[0].createTextRange();
if (r != null) {
r.text = "Clicked";
}
}
</SCRIPT>
Standards Information
There is no public standard that applies to this object.
#############################################
scrollIntoView Method
--------------------------------------------------------------------------------
Causes the object to scroll into view, aligning it either at the top or bottom of the window.
Syntax
object.scrollIntoView( [bAlignToTop])
Parameters
bAlignToTop Optional. Booleanthat specifies one of the following values: true Default. Scrolls the object so that top of the object is visible at the top of the window.
false Scrolls the object so that the bottom of the object is visible at the bottom of the window.
Return Value
No return value.
Remarks
The scrollIntoView method is useful for immediately showing the user the result of some action without requiring the user to manually scroll through the document to find the result.
Depending on the size of the given object and the current window, this method might not be able to put the item at the very top or very bottom, but will position the object as close to the requested position as possible.
Example
This example uses the scrollIntoView method to underline the content of the document's fifth paragraph and scroll it into view at the top of the window.
var coll = document.all.tags("P");
if (coll.length >= 5)
{
coll(4).style.textDecoration = "underline";
coll(4).scrollIntoView(true);
}
Standards Information
There is no public standard that applies to this method.
Applies To
A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, controlRange, CUSTOM, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, hn, HR, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NOBR, OBJECT, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TextRange, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, WBR, XMP
================================================================
Nachfolgend die Collectionen vom Objekt document im HTML-DOM des
Internet Explorers
Collections
Collection Description
all Returns a reference to the collection of elements contained by the object.
anchors Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order.
applets Retrieves a collection of all applet objects in the document.
childNodes Retrieves a collection of HTML Elements and TextNode objects that are direct descendants of the specified object.
embeds Retrieves a collection of all embed objects in the document.
forms Retrieves a collection, in source order, of all form objects in the document.
frames Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window.
images Retrieves a collection, in source order, of img objects in the document.
links Retrieves a collection of all a objects that specify the HREF property and all area objects in the document.
namespaces Retrieves a collection of namespace objects.
scripts Retrieves a collection of all script objects in the document.
styleSheets Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document.