moveToPoint Method

DHTML, HTML, & CSS

moveToPoint Method


Moves the start and end positions of the text range to the given point.

Syntax

TextRange.moveToPoint(iX, iY)

Parameters

iXRequired. Integer that specifies the horizontal offset relative to the upper-left corner of the window, in pixels.
iYRequired. Integer that specifies the vertical offset relative to the upper-left corner of the window, in pixels.

Return Value

No return value.

Remarks

The coordinates of the point must be in pixels and be relative to the upper-left corner of the window. The resulting text range is empty, but you can expand and move the range using methods such as expand and moveEnd.

This feature might not be available on non-Win32® platforms. For the latest information about Internet Explorer cross-platform compatibility, see article q172976Internet Link Non-MSDN link in the Microsoft Knowledge Base.

Example

This example uses the moveToPoint method to move the text range to the point where the user clicked the mouse, expands the range, and selects the text within the new range.

<SCRIPT FOR=document EVENT=onclick LANGUAGE="JScript">
    var rng = document.body.createTextRange();
    rng.moveToPoint(window.event.x, window.event.y);
    rng.expand("word");
    rng.select();
</SCRIPT>

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.

TextRange


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.