wrote:
> Hello,
>
> Anyone that can think of a way to programmaticaly determine the word
on
> an HTML page that the user clicked on will be my hero for life.
>
> Leo
Not that hard in IE, using a textRange...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
body {
font: normal 14px "comic sans ms";
color: darkred;
}
..silver {
background: silver;
}
</style>
<script type="text/javascript">
function grabword(e)
{
var tgt;
if ((e = e || window.event)
&& (tgt = e.srcElement || e.target)
&& !/((^A$)|(INPUT))/i.test(tgt.tagName))
{
rng = document.body.createTextRange();
rng.moveToPoint(e.x, e.y);
rng.expand('word');
document.forms[0].t.value += '~ ' + rng.htmlText + '\n';
rng.pasteHTML('<span class="silver">' + rng.htmlText + '</span>');
}
}
document.onclick = grabword;
</script>
</head>
<body>
Anyone that can think of a way to programmaticaly determine the word on
an HTML page that the user clicked on will be my hero for life.
<form>
<textarea name="t" style="width:150px;height:300px;overflow:hidden;">
</textarea>
</form>
</body>
</html>
Another matter elsewhere. See if this helps:
http://www.faqts.com/knowledge_base/...html/aid/33674