//
复制
function
Copy(id) {
var
obj = document.getElementById(id);
CopyText(obj);
}
function
CopyText(obj) {
if
(! -[1, ]) {
var
rng = document.body.createTextRange(); //
列出所有文本对象内容
rng.moveToElementText(obj); //
移动文本范围以便范围的开始和结束位置能够完全包含给定元素的文本
rng.scrollIntoView(); //scrollIntoView
将对象滚动到可见范围内,将其排列到窗口顶部或底部
rng.select(); //
选择
rng.execCommand("Copy"
); //
复制
rng.collapse(false
);
//window.clipboardData.setData('text',
$(obj).html()); //
这一句 实现复制
alert("
复制成功"
);
}
}