This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
Selection.modify() method applies a change to the current selection or cursor position, using simple textual commands.
sel.modify(alter, direction, granularity)
- The type of change to apply. Specify
"move"to move the current cursor position or
"extend"to extend the current selection.
- The direction in which to adjust the current selection. You can specify
"backward"to adjust in the appropriate direction based on the language at the selection point. If you want to adjust in a specific direction, you can specify
- The distance to adjust the current selection or cursor position. You can move by
"documentboundary". Webkit and Blink do.
Note: Starting in Gecko 5.0, the
"word" granularity no longer includes the following space, regardless of the default platform behavior. This makes the behavior more consistent, as well as making it work the same way WebKit used to work, but unfortunately they have recently changed their behavior.
To extend the current text selection to include the next word:
var selection = window.getSelection(); selection.modify("extend", "forward", "word");
This method is not part of any specification.
|Feature||Chrome||Firefox (Gecko)||Internet Explorer||Opera||Safari (WebKit)|
|Basic support||?||4.0 (2)||?||?||?§|
|Feature||Android||Firefox Mobile (Gecko)||Firefox OS||IE Phone||Opera Mobile||Safari Mobile|
|Basic support||?||4.0 (2)||1.0||?||?||?|
Selection, the interface it belongs to.
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.