lqzhgood
11/14/2018 - 3:09 AM

[html] html #html

[html] html #html

// 复制文字 修复 ios bug
function copyText(text, succ, err) {
    text = text.toString();
    let copyDom = document.createElement('textarea');
    copyDom.setAttribute('readonly', 'readonly');
    copyDom.setAttribute('value', text);
    copyDom.value = text;
    copyDom.readonly = 'readonly';
    document.body.appendChild(copyDom);
    copyDom.select();
    copyDom.setSelectionRange(0, 9999);
    if (document.execCommand('copy')) {
        document.execCommand('copy');
        succ && succ();
    } else {
		err && err();
	}
    document.body.removeChild(copyDom);
    copyDom.remove();
}