Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy to clipboard?
#4
(04-23-2018, 04:06 AM)mhammady Wrote: How do you call this script to make sure it is executed? Also, the label name would be in uppercase if I'm not mistaken. Did you debug your code in the browser?

Mohamed

I do the javascript in ScriptEvents , for the onClick ....

If I do just a simple alert call, that executes, so I know javascript is running via this method.

(04-23-2018, 04:06 AM)DanBarclay Wrote:
(04-23-2018, 03:22 AM)cpstevenc Wrote: Using 14.2.7 with Tokyo Update 3 , HTTPS enabled.

I have a TIWLabel , that uses RawText = true, which for now is named ( and friendly name) lbl_NumberText

I want to be able to copy the text inside this to the clipboard.

I already know this is tricky in itself, depending on Browser... browser version... http vs https.

Using this as an example @ https://www.w3schools.com/howto/howto_js...pboard.asp

I use the onClick ScriptEvent on a button do just do the javascript code


Code:
var copyText = document.getElementById("lbl_NumberText");
    copyText.select();
    document.execCommand("Copy");
    alert("Copied the text: " + copyText.value);

This appears to not work as it never gets to the "alert" section .... I assume the script code is aborting as I am sure "lbl_NumberText" for getElementById is not quite correct.

Instead of the .FriendlyName, try using .Name.

The control id is what you're looking for.  When I look at the DOM, that shows .Name in the id.

Dan

"LBL_NUMBERTEXTFRAME_STRONGS"

Is what I see looking at the DOM via Chrome.

This is in a FRAME ... and this is in "Tframe_Strongs" , so assume where STRONGS is coming from on that part.

I tried that already last night but it doesn't seem to work.

I changed up the javascript to do a try / catch


Code:
try
{
copyText = document.getElementById("LBL_NUMBERTEXTFRAME_STRONGS");
copyText.select();
document.execCommand("Copy");
alert("Copied the text: " + copyText.value);
}
 catch(err)
{
 alert(err.message); 
}

And I get an alert from the catch , "copyText.select is not a function" 

Which I take it as, the getElementById didn't hook into anything, then the next call being select, fails.
Reply


Messages In This Thread
Copy to clipboard? - by cpstevenc - 04-23-2018, 03:22 AM
RE: Copy to clipboard? - by mhammady - 04-23-2018, 04:06 AM
RE: Copy to clipboard? - by cpstevenc - 04-23-2018, 02:20 PM
RE: Copy to clipboard? - by DanBarclay - 04-23-2018, 04:06 AM
RE: Copy to clipboard? - by kudzu - 04-23-2018, 04:49 PM
RE: Copy to clipboard? - by cpstevenc - 04-23-2018, 06:05 PM
RE: Copy to clipboard? - by DanBarclay - 04-23-2018, 10:41 PM
RE: Copy to clipboard? - by Jose Nilton Pace - 04-24-2018, 02:30 PM
RE: Copy to clipboard? - by cpstevenc - 04-24-2018, 08:49 PM
RE: Copy to clipboard? - by Jose Nilton Pace - 04-24-2018, 09:34 PM
RE: Copy to clipboard? - by kudzu - 04-25-2018, 03:16 PM
RE: Copy to clipboard? - by cpstevenc - 04-30-2018, 02:20 AM
RE: Copy to clipboard? - by DanBarclay - 05-01-2018, 01:40 AM
RE: Copy to clipboard? - by kudzu - 04-30-2018, 01:43 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)