Using Martin Honnen's code, and helpfull advice/links from others, I
have a working solution that I am providing below. If others have
advice or other solutions, feel free to share!
Thanks everyone, especially Martin.
A.L.
<html lang="en">
<head>
<title>Restricting the selection in IE from partial HTML tags</title>
<script type="text/javascript">
function CorrectSelection (textControl)
{
if (typeof document.selection != 'undefined' && typeof
document.selection.createRange != 'undefined')
{
// grab highlight
var range = document.selection.createRange();
if (range.parentElement() == textControl && typeof range.expand
!= 'undefined')
{
// grab the content of highlight, and modify if necessary
var rangeContent = document.selection.createRange().text
// if it picks up partial tag at start, move one char right
if(rangeContent.substring(0,2)=='><')
range.moveStart('character', 1);
// if it picks up partial tag "<" at end, move one char left
if(rangeContent.substring(rangeContent.length-2,rangeContent.length)=='><')
range.moveEnd('character', -1);
// if it picks up partial tag "</" at end, move two chars
left
if(rangeContent.substring(rangeContent.length-2,rangeContent.length)=='</')
range.moveEnd('character', -2);
range.select();
}
}
}
</script>
</head>
<body>
<h1>Restricting the selection in IE from partial HTML tags</h1>
<form action="" onsubmit="return false;">
<div>
<textarea name="textareaName" rows="5" cols="80"
onMouseUp="CorrectSelection(this.form.elements.tex tareaName);"
<br><span class=headline>DEFAULT.ASP</span><br>
<u><span class=normal>Just some text...</span></u>
</textarea>
</div>
</form>
</body>
</html>