showModalDialog的界面内容不能拷贝

今天,用showModalDialog弹出一个对话框,但上面的标签却不能拷贝,
1.htm
<html>
<body>
<input type="button" onclick="window.showModalDialog('2.htm','','');" />
</body>
</html>

2.htm
<html>
<body>
拉选这段文字,并复制
</body>
</html>

查来查去,找出几个方案:一是把标签用文本框代替。
另一种是,对标签加上一段代码:
2.htm
<html>
<body>
<span id="Lab1">拉选这段文字,并复制</span>
<script>
 document.all["Lab1"].contentEditable = "True";
</script>
</body>
</html>
contentEditable=true是让内容变为设计模式,这要不仅可以拷贝,还可以修改,默认值为"inherit"。在一些自定义功能强的地方有应用。如果让整个body的contentEditable变为true,则里面的东西就可以乱拉了,对我这次的应用也不好。

原文地址:https://www.cnblogs.com/yzx99/p/1348954.html