moveStart method (Internet Explorer)

Switch View :
ScriptFree
moveStart method

Changes the start position of the range.

Syntax

object.moveStart(Unit, Count)

Standards information

There are no standards that apply here.

Parameters

Unit [in]

Type: BSTR

String that specifies the units to move, using one of the following values:

character

Moves one or more characters.

word

Moves one or more words. A word is a collection of characters terminated by a space or other white-space character, such as a tab.

sentence

Moves one or more sentences. A sentence is a collection of words terminated by a punctuation character, such as a period.

textedit

Moves to the start or end of the original range.

Count [in, optional]

Type: long

Integer that specifies the number of units to move. This can be positive or negative. The default is 1.

Return value

Type: Integer

Integer that returns the number of units moved.

Remarks

This feature might not be available on non-Microsoft Win32 platforms.

See also

TextRange
TextRange Constructor
Reference
move
moveEnd

 

 

Send comments about this topic to Microsoft

Build date: 2/14/2012

Community Content

Shawn Eary
MoveStart Example
<html>
<head>
<title>moveStart Example</title>
<script type="text/javascript">
// Function to demonstrate the use of moveStart by erasing
// the last word in "someTextArea"  
//
// Note that this example function does not work well with 
// punctuation.
function eraseLastWord() {
var theTextArea = document.getElementById("someTextArea");
var theTextRange = theTextArea.createTextRange();

// Select the last word in the TextRange by advancing 
// the Start pointer of the TextRange to the end and then
// moving back one word
theTextRange.moveStart("textedit");
theTextRange.moveStart("word", -1);

// Now that the last word of the TextArea is selected in 
// the text range, erase it
theTextRange.text = ""; 
}
</script>
</head>
<body>
<textarea id="someTextArea" 
rows="3" cols="40">Some initial text to play with</textarea>
<input type="button" value="Erase Last Word" 
onclick="eraseLastWord();" />
</body>
</html>