window.showModalDialog()复制内容

ShowModalDialog 打开 页面上加入个

  1. <span id="mySpan" name="mySpan" contentEditable="true">
  2. </span>
<span id="mySpan" name="mySpan"  contentEditable="true">
    
    
</span>
span 里内容就可以被复制

实例

1.htm
<html>
<body>
<input type="button" οnclick="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"。在一些自定义功能强地方有应用。如果让整个bodycontentEditable变为true,则里面东西就可以乱拉了,对我这次应用也不好。

转载于:https://www.cnblogs.com/love828/p/3176612.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值