Skip to main content
PATurmel12
Inspiring
Dec 20, 2023 5:49 PM UTC
Question

How to reference the HTML DOM using Animate Canvas.

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 is closed to new replies. Start a new post to keep the conversation going.

9 replies

PATurmel12
Inspiring
Jan 2, 2024 4:17 PM UTC

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.

 

Translate
kglad
Community Expert
Community Expert
Jan 2, 2024 4:38 PM UTC

i don't see an error in chrome.  

 

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

Translate
PATurmel12
Inspiring
Jan 2, 2024 4:56 PM UTC

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 ).

Translate
PATurmel12
Inspiring
Jan 2, 2024 1:17 PM UTC

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);
				 }

 

Translate
kglad
Community Expert
Community Expert
Jan 2, 2024 2:08 PM UTC

use naviagator.clipboard.writeText()

Translate
kglad
Community Expert
Community Expert
Dec 21, 2023 2:10 AM UTC

use document.getElemtnById()

Translate