<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>getSelection方法</title>
<script language="javascript">
function showSelection()
{
document.forms[0].selectedText.value=document.selection.createRange().text;
}
document.onmouseup=showSelection
</script>
</head>
<body>
<b>请选中页面中的一些文本</b>
<hr>
<p>这些都是用来测试的文本,可以用鼠标来选中,然后试一试</p>
<form>
<textarea name="selectedText" rows=3 cols=40 wrap="virtual"></textarea>
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>getSelection方法</title>
<script language="javascript">
function showSelection()
{
document.forms[0].selectedText.value=document.selection.createRange().text;
}
document.onmouseup=showSelection
</script>
</head>
<body>
<b>请选中页面中的一些文本</b>
<hr>
<p>这些都是用来测试的文本,可以用鼠标来选中,然后试一试</p>
<form>
<textarea name="selectedText" rows=3 cols=40 wrap="virtual"></textarea>
</form>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货