`
sohighthesky
  • 浏览: 34752 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

javascript 复制图片(IE only)

阅读更多
<img src="http://www.uedsky.com/sky/demo/images/imagezoom/tong_s.jpg" id="img1"/>
<input type="button" id="btn1" value="Copy Image"/>
<script>
function CopyImage(img) {
	if (img.tagName === 'IMG' && document.body.createControlRange) {
        var ctrl = document.body.createControlRange(); 
        //img.contentEditable = true; 
        ctrl.addElement(img); 
        ctrl.execCommand('Copy'); 
        //img.contentEditable = false; 
        alert('复制完成,可以到QQ对话框里按Ctrl+V啦!'); 
	}
} 
(function(){
var $=function(id){return document.getElementById(id)}
$("btn1").onclick=function(){
    var img=$("img1");
    CopyImage(img)
}
})();
</script>

From : http://lqixv.iteye.com/blog/231426

另外:table 的rules属性:
<TABLE ID="oID_1" RULES="cols">
<THEAD>
<TR>
<TD>EST</TD><TD>1am</TD><TD>8pm</TD>
</TR>
</THEAD>
<TR>
<TD>CST</TD><TD>2am</TD><TD>9pm</TD>
</TR>
<TR>
<TD>MST</TD><TD>3am</TD><TD>10pm</TD>
</TR>
<TFOOT>
<TR>
<TD>PST</TD><TD>4am</TD><TD>11pm</TD>
</TR>
</TFOOT>
</TABLE>
<P>
<BUTTON onclick="document.getElementById('oID_1').rules=''">No borders</BUTTON>
<BUTTON onclick="document.getElementById('oID_1').rules='none'">Exterior border</BUTTON>
<BUTTON onclick="document.getElementById('oID_1').rules='all'">All borders</BUTTON><BR>
<BUTTON onclick="document.getElementById('oID_1').rules='cols'">Column borders</BUTTON>
<BUTTON onclick="document.getElementById('oID_1').rules='groups'">Groups borders</BUTTON>
<BUTTON onclick="document.getElementById('oID_1').rules='rows'">Table row borders</BUTTON>
</P>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics