Forum Discussion

  • Oh, okay. The question was how.. Try this after the copy command:

    setTimeout(function() {textArea.remove();}, 1000);

    1000 is a second delay. You can adjust that if you want. 
  • I'm glad you were able to create a solution, Crystal. I appreciate you chiming in to share, and welcome to E-Learning Heroes. 😊

  • Zsolt Olah

    In my advanced Storyline session at the ATD TechKnowledge conference people asked me if there's a way to copy text from a variable to the clipboard programmatically, so the user can paste it somewhere. 

    Yes, try this (using JavaScript):

    https://www.rabbitoreg.com/examples/p99/#/lessons/NPQ2NG0PlDgwjy_ZLbmw6t0PPaoWFEB6

     

    Thanks got this Zsolt - just built an troubleshooter that sits in an iframe pop-up within one of our tools, and this JS copies some text across to an email which can then be sent straight to our IT dept when things go wrong. Super useful!

     

    Last piece of the jigsaw. When the text is copied, in the top left of the browser it shows a text box with the copied text. I believe this is because the JS creates the textboc then copies its contents. So how can I get the textbox to delete after this has taken place?

    Thanks for any help!

  • Hi Martin,

    Yes, a new text box is created with the text, and the content is copied to the clipboard. We do not need that text box after. It can be deleted. 

  • YuYingLin's avatar
    YuYingLin
    Community Member

    Hello! Thank you for this function. I am planning to use it for my e-learning project. There's one question: if I want to have several lines in the text, how can I do that?

    For example, there's a code I want my learners to copy like the following:

     

    cd git-fundamental-repo01

    echo "hello world" > file1.txt

    cat file1.txt

     

    How can I make it happen in just one click?

     

     

  • Hi Zsolt thank you so much for sharing this! I was hoping to ask if you have a way as well to paste text to a text entry with a live word count. Currently, I only configure my word count if the user starts typing. However when a text is copied and pasted in the text entry-- it does not recognize the word count anymore. Appreciate your help on this. Attached for your reference. 

  • Hi Zsolt, thank you for sharing your link. Super helpful.

    I have linebreaks in the text to be copied that I want to preserve when it's copied to the clipboard. For example

    John Smith

    Jane Doe

    Peter White

    In the input box for the storyline variable, I have no option to include linebreaks and can only render "John Smith Jane Doe Peter White". I've tried adding <br>in the text where I want the linebreak to appear, but that's not working. The copied text also includes the <br> rather than interpreting it as code.

    Is there a way to preserve linebreaks in the output text when using your code to copy to clipboard?