Disabling Script

The question is how can I turn off/on script in other script?
image
I tried this, but it doesn’t work

1 Like

Hey @sAp , you can find the entity on which that script is attached and then can get the reference of it to disable it.

var entity = this.app.root.findByName("UIEntityName");
var scriptRef = entity.script.ui;
scriptRef.enabled = false;
1 Like

Thank u! It works!

1 Like

I found one more problem. The script I turn off/on is an html/css add script. So if I turn it on, then script works and displays my web content. But when I want to turn it off, the script turns off, but the content is still on the screen. What should I do?

1 Like

html will not be disabled by disabling the script or the entity. You will have to find that html id and disable it’s display individually. Here is how you can do it.

document.getElementById("class id").style.display = "none";
1 Like