Skip to main content
PATurmel12
Inspiring
December 20, 2023
Question

How to reference the HTML DOM using Animate Canvas.

  • December 20, 2023
  • 3 replies
  • 357 views

How do I use something like

 

document.getElementByName();

 

using javascript.  

 

I get an error in the Javascript console on Safari

TypeError: undefined is not an object

 

Got it.   Load it up to server.   Doesn't work on local envirenment.

This topic has been closed for replies.

3 replies

PATurmel12
Inspiring
January 2, 2024

Google Chrome javascript console says,

 

Uncaught (in promise) DOMException: Document is not focused.

 

Looks as if there is a security update in browsers to prevent dynamically writing to the clipboard.

 

kglad
Community Expert
Community Expert
January 2, 2024

i don't see an error in chrome.  

 

is that function on the main timeline and called from the main timeline?

PATurmel12
Inspiring
January 2, 2024

This is on the main timeline.  This function used to work but a few months ago stopped working.  I am working on a workaround ( javascript alert or downloadable text file should work for my purposes ).

PATurmel12
Inspiring
January 2, 2024

Here's the code I cannot get to work.

 

This is in the javascript file Animate produces with Canvas. 

 

 

				function copyStringToClipboard (str) {
				 const el = document.createElement('textarea');
  el.value = str;
  document.body.appendChild(el);
  el.select();
  el.setSelectionRange(0,999999999999);
  document.execCommand('copy');
  document.body.removeChild(el);
				 }

 

kglad
Community Expert
Community Expert
January 2, 2024

use naviagator.clipboard.writeText()

kglad
Community Expert
Community Expert
December 21, 2023

use document.getElemtnById()