question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Faulty behaviour when browser access is not permitted.

See original GitHub issue

Hello,

This is a bit of an edge-case and might not have a proper solution. But since the project supports IE9+ and I’d qualify this as a “case where you’d like to show some user feedback”.

I thought I’d be worth mentioning here.

Steps to reproduce:

  1. Visit http://zenorocha.github.io/clipboard.js/
  2. Click one of the triggers in the examples
  3. Click on deny access, when prompted for clipboard permissions by the browser. (see screenshot)
  4. UI responds as if the copy to clipboard succeeded. (see screenshot)

AFAIK the root cause of the problem is that document.execCommand returns true even if it does not have permissions.

  • OS: Windows 7 (Home Premium)
  • Browser Version: IE 9 (see screenshot)

permission copied version

Thanks for a great library with superb documentation. Cheers.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tmakincommented, Feb 5, 2018

The following error trap is working for me on IE11 inside my success handler

const clipboardData = window['clipboardData'];
if (clipboardData && clipboardData.getData) {
  if (!clipboardData.getData('Text')) {
    // display failure message
    return;
  }
}
0reactions
dongyanghecommented, May 9, 2019

因为之前可能已经有复制内容,会导致误判,所以我加了剪切板的内容对比,这样可能会比较完整:

copyeSuccessFun:  function(e) {
        if (!ClipboardJS.isSupported()) {
            //  copyeErrorFun()
           console.log('复制失败');
            return
        }
        const clipboardData = window['clipboardData'];
        if (clipboardData && clipboardData.getData) {
            if (!clipboardData.getData('Text') || e.text != clipboardData.getData('Text')) {
                //  copyeErrorFun()
                console.log('复制失败');
                return;
            }
        }
        console.log('复制成功');
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling common HTML and CSS problems - MDN Web Docs
Browsers not supporting modern features. This is a common problem, especially when you need to support old browsers (such as Internet Explorer) ...
Read more >
403 Forbidden Error - What Is It and How to Fix It
The 403 Forbidden error happens when a web server denies access to a webpage to a user trying to access it trough a...
Read more >
Access denied when you call Web Service
This article helps you resolve errors (Access Denied) that occur when you call a Web service application and Anonymous access authentication ...
Read more >
Upcoming Browser Behavior Changes: What Developers ...
Learn about upcoming changes to browser cookie behavior that may make your web applications incompatible.
Read more >
Troubleshooting Chrome Web Store violations
Extensions with broken functionality—such as dead sites or non-functioning features—are not allowed. # Excessive permissions. Corresponds to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found