 Inside Technique : The Word By Scott Isaacs
Demonstrates using the textRange object to determine what word the mouse is over in the document. As you move the mouse over different words in your document, the status bar is updated with the word.
Code
function doMouseMove() {
var tr = document.body.createTextRange();
tr.moveToPoint(event.clientX, event.clientY);
// Expand to the entire word under the mouse.
tr.expand("word");
window.status = tr.text;
}
document.onmousemove = doMouseMove;
Discuss and Rate this Article© 1997-2000 InsideDHTML.com, LLC. All rights reserved. |