展开全部
写了个例子,看看是不是符合要求:
<html>
<head>
<script>
function getSelectedText() {
if (window.getSelection) { // This technique is the most likely to be standardized.
// getSelection() returns a Selection object, which we do not document.
return window.getSelection().toString();
} else if (document.getSelection) { // This is an older, simpler technique that returns a string
return document.getSelection();
} else if (document.selection) { // This is the IE-specific technique.
// We do not document the IE selection property or TextRange objects.
return document.selection.createRange().text;
}
}
function copy() {
var tmpText = getSelectedText();
tRight.value += tmpText;
}
</script>
</head>
<body>
<table width="100%">
<tr>
<td width="45%" align="center"><textarea id="tLeft" rows="10" cols="50"></textarea></td>
<td><input type="button" onclick="copy()" value=">>>>>>" /></td>
<td width="45%" align="center"><textarea id="tRight" rows="10" cols="50"></textarea></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<script>
function getSelectedText() {
if (window.getSelection) { // This technique is the most likely to be standardized.
// getSelection() returns a Selection object, which we do not document.
return window.getSelection().toString();
} else if (document.getSelection) { // This is an older, simpler technique that returns a string
return document.getSelection();
} else if (document.selection) { // This is the IE-specific technique.
// We do not document the IE selection property or TextRange objects.
return document.selection.createRange().text;
}
}
function copy() {
var tmpText = getSelectedText();
tRight.value += tmpText;
}
</script>
</head>
<body>
<table width="100%">
<tr>
<td width="45%" align="center"><textarea id="tLeft" rows="10" cols="50"></textarea></td>
<td><input type="button" onclick="copy()" value=">>>>>>" /></td>
<td width="45%" align="center"><textarea id="tRight" rows="10" cols="50"></textarea></td>
</tr>
</table>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询