Mobile browser to realize replication

currently uses clipboard , but it is found to be incompatible under ios10. Is there any good way to copy to the clipboard?

Feb.28,2021

No, unsupported prompt to copy manually


try this

document.addEventListener('click', function bindCopy(e) {
    dom = document.createElement('textarea');
    // Prevent zooming on iOS
    dom.style.fontSize = '12pt';
    // Reset box model
    dom.style.border = '0';
    dom.style.padding = '0';
    dom.style.margin = '0';
    // Move element out of screen horizontally
    dom.style.position = 'absolute';
    dom.style['left'] = '-9999px';
    // Move element to the same position vertically
    var yPosition = window.pageYOffset || document.documentElement.scrollTop;
    dom.style.top = yPosition + 'px';

    dom.setAttribute('readonly', '');
    dom.value = '';

    document.body.appendChild(dom);

    dom.select();
    dom.setSelectionRange(0, dom.value.length);
    document.execCommand('copy');
    document.removeEventListener('click', bindCopy);
})
Menu