<p>A paragraph with some nice text in it</p>
<script type="text/javascript">
function expandSelection() {
var sel;
if (window.getSelection) {
sel = window.getSelection();
if (sel.modify) {
sel.modify("extend", "forward", "word");
}
}
}
</script>
<input type="button" onclick="expandSelection();" value="expand">