<head>
<script LANGUAGE="JavaScript">
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function showSelection(){
if (window.getSelection) {
alert(window.getSelection());
document.forms[0].selectedText.value=window.getSelection();
} else if (document.getSelection) {
alert(document.getSelection());
document.forms[0].selectedText.value=document.getSelection();
} else if (document.selection) {
alert(document.selection.createRange().text);
document.forms[0].selectedText.value=document.selection.createRange().text;
}
}
if (isNav) {
document.captureEvents(Event.MOUSEUP);
}
document.onmouseup = showSelection;
</script>
</head>
<body>
<P>
这些都是用来测试的文本,您可以用鼠标来选中,然后试一试选择文本后产生的结构。
</P>
<form name="dataholder">
<textarea name="selectedText" rows = 3 cols=40 wrap="virtusl">
</textarea>
</form>
</body>
posted on 2007-07-16 12:51
lcgxc 阅读(3922)
评论(0) 编辑 收藏 所属分类:
javascript