How to change attributes in the main HTML node

What I’m trying to do:
In order to disable translation, I want to the main html node to look like this:

<html lang="en" translate="no" class="notranslate ..">
..
</html>

What I’ve tried and what’s not working:
I tried to access the DOM through anvil.js.window.document, but got a bit stuck.

I’m hoping this will be quick for someone who has done this to answer or to point me in the right direction.

1 Like

Have you tried Assets or Native Libraries?

image
image

Or is that not where you want your html? Maybe I’m missing something.

Maybe you could start with a Custom HTML template and then load the rest of your app from inside it?

Hi @stein,

I think you’re looking for:

from anvil.js.window import document

document.querySelector("html").setAttribute("translate", "no")
1 Like