1

I have a website which will only be accessed via browsers I have full control of and I want to access the clipboard on load. I can't use the Clipboard API, since the website is served locally or over http (not https). I also can't use e.clipboardData.getData('text/plain'), since I don't have an event to call it on. Any ideas on how to access the Clipboard?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Teiem
  • 1,329
  • 15
  • 32
  • Clipboard API should work with `localhost` as is, otherwise you can check this flag `chrome://flags/#unsafely-treat-insecure-origin-as-secure`. Not sure about Firefox. – Walk Mar 08 '20 at 21:28
  • @Walk the flag sadly doesn't work for local websites – Teiem Mar 08 '20 at 21:36
  • I see, perhaps you can create a small browser extension. These can access clipboard, see https://stackoverflow.com/questions/22702446/how-to-get-clipboard-data-in-chrome-extension/43375402 – Walk Mar 08 '20 at 21:41
  • Did you try using the Clipboard API? Its not dependent on the protocol – Anurag Srivastava Mar 08 '20 at 21:53
  • 1
    @AnuragSrivastava the api can only be used in a "Secure context", aka over https – Teiem Mar 08 '20 at 22:07
  • @Teiem — So use HTTPS. Get a self-signed cert for your internal services. – Quentin Mar 09 '20 at 09:41

0 Answers0