Script to copy code

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

Post Reply
John Johann
Posts: 177
Joined: Mon Aug 21, 2017 7:35 pm

Script to copy code

Unread post by John Johann » Tue Aug 13, 2019 8:54 pm

I've probably missed it when searching, but is there a script somehwere to copy a block of code from a published CHM into the clipboard?

User avatar
Tim Green
Site Admin
Posts: 21689
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Script to copy code

Unread post by Tim Green » Wed Aug 14, 2019 7:16 am

Hi John,
I've probably missed it when searching, but is there a script somehwere to copy a block of code from a published CHM into the clipboard?
The JavaScript document.execCommand("copy") command will copy the currently selected text to the clipboard. However, for security reasons it only works in edit mode (i.e. within editable fields and text editing boxes), so you would need to display the code in an editable box to be able to select it. It's really much easier to put your code example in a table cell and let the user select it and copy it with right-click. 8)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.

Post Reply