Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work on Safari 12 - TypeError: undefined is not an object (evaluating 'navigator.clipboard.writeText') #74

Closed
ffxsam opened this issue Jun 29, 2021 · 2 comments

Comments

@ffxsam
Copy link

ffxsam commented Jun 29, 2021

Apparently this library relies on navigator.clipboard which doesn't exist in Safari 12.

@sindresorhus
Copy link
Owner

This is already documented in the readme.

@ffxsam
Copy link
Author

ffxsam commented Jun 29, 2021

So, how is this library different from me just calling navigator.clipboard.writeText directly? I'd think this library could offer an added benefit by having a fallback for older browsers:

function setClipboard(value) {
    const tempInput = document.createElement('input');

    tempInput.style.position = 'absolute';
    tempInput.style.left = '-1000px';
    tempInput.style.top = '-1000px';
    tempInput.value = value;
    document.body.appendChild(tempInput);
    tempInput.select();
    document.execCommand("copy");
    document.body.removeChild(tempInput);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants