在我的 Mac 上试过这个似乎可以在 Safari/Chrome 和 FF 上运行,但不确定 IE
<head>
<script>
var mouseup_fun = function()
{
var str = document.getSelection().toString();
if (str.length > 0) {
document.getElementById("div2").innerHTML = str;
}
}
</script>
</head>
<body >
<div id="div1" onmouseup="mouseup_fun()">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</br></br>
<div id="div2">
</div>
</body>
</html>