Jump to content

Cant execute document.execCommand


Kast2k

Recommended Posts

Dear colleagues,

I created a demo of receiving screenshot from clipboard (attached), but it works only if you are pressing Ctrl+V.

If i add this code on Button click then no result.

  UniSession.AddJS(
    'document.execCommand(''paste'');'
  );

Could you please show what am i doing wrong? How can i simulate Ctrl+V combination?

Thank You.

UniGUIClipboardImage.zip

Link to comment
Share on other sites

  • 1 year later...

https://stackoverflow.com/a/53448633/2176869

Calling document.execCommand("paste") is not supported by "reasonable" browsers, because of security concerns as it might enable the script to read sensitive data (like passwords) from the clipboard.

This is the compatibility matrix of document.execCommand("...") concerning clipboard events:

  "copy" "paste" "cut"
IE OK OK n/a
Edge OK n/a OK
Firefox OK n/a OK
Chrome OK n/a OK
Link to comment
Share on other sites

1 hour ago, Daha Software said:

What is the solution to this?
I want to click on a button to apply CTR + V,
But Clipboard does not work on the client only on the server


procedure TUniNF.UniButton1Click (Sender: TObject);
begin
Uniedit1.text: = Clipboard.AsText;
end;

Due to security reasons,the browsers are not letting you document.execCommand("paste")

There is no solution

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...