Web Core CopyToClipboard

Greetings,

When using the TWebClipBoard component, I get an error when trying to use the CopyToClipboard command.

This is the only piece of code regarding the TWebClipBoard component:

procedure BtnCopyThreadLinkClick(Sender: TObject);
  var
    Tcp: TWebClipBoard;
  begin
    Tcp:=TWebClipBoard.Create;
    Tcp.CopyToClipboard(Application.EXEName +'?ViewThread=' +AObject.GetJSONValue('Thread_ID'));
    Tcp.Free;
  end;

Now, when running this in localhost I get no error. But when deploying the project to the IIS, I get the following error in Google Chrome:

Uncaught TypeError: Cannot read property 'writeText' of undefined
at Object.rtl.module.rtl.createClass.CopyToClipboard
at Object.g.FOnClick
at Object.rtl.module.rtl.createClass.Click
at Object.rtl.module.rtl.createClass.HandleDoClick
at HTMLButtonElement.i

In Firefox, the error is as follows:

Uncaught TypeError: window.navigator.clipboard is undefined
CopyToClipboard
FOnClick
Click
HandleDoClick

What might be the reason/solution to this problem?

Kind regards.

Hi,

TWebClipBoard.CopyToClipboard uses the Async Clipboard API which requires secure context. From your error messages it seems like you are using HTTP instead of HTTPS.