copytext("需要复制的内容",function(){
alert("复制成功!");
});
function copytext(txt,cd){
var Url2 = txt;
var oInput = document.createElement('input');
oInput.value = Url2;
document.body.appendChild(oInput);
// oInput.select();
selectText(oInput)
document.execCommand("Copy");
oInput.className = 'oInput';
oInput.style.display = 'none';
cd();
};
function selectText(oInput) {
if(oInput.createTextRange) {//ie
oInput.select();
}else{//firefox/chrome
oInput.setSelectionRange(0, oInput.value.length);
oInput.focus();
};
};
js 点击复制功能兼容
猜你喜欢
转载自www.cnblogs.com/zjhuanjing/p/12572680.html
今日推荐
周排行