Advertisement:

Author Topic: Select and copy javascript  (Read 268 times)

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,718
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Select and copy javascript
« on: February 24, 2019, 07:06:13 AM »
Currently, if one adds the code tag, the
Code: [Select]
smfSelectText(this); bit allows to select the code. Could this be improved so that it copies too?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,508
    • StoryBB/StoryBB on GitHub
Re: Select and copy javascript
« Reply #1 on: February 24, 2019, 07:42:21 AM »
The clipboard API is very fussy about what it allows you to do because code being allowed to copy to the clipboard carries security implications. Most of the time this is offered by Flash based fallbacks, so you can see how useful that’s going to be...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,718
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,508
    • StoryBB/StoryBB on GitHub
Re: Select and copy javascript
« Reply #3 on: February 24, 2019, 08:45:45 AM »
If Google Docs can't do it consistently in a major browser and puts up a prompt telling people to use Ctrl-C on their keyboard (as in Firefox)... I doubt this really works as well as advertised.

Even putting that aside it cannot be added to smfSelectText in 2.0 as this is needed for other routines and one of the huge deals of the clipboard API is that you can't call it directly from a function but have to trigger it only in an event handler for security reasons.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,718
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Re: Select and copy javascript
« Reply #4 on: March 13, 2019, 07:13:00 AM »
It works just fine in Adsense and http://goo.gl :)
« Last Edit: March 13, 2019, 07:39:57 AM by spiros »