How to execute script immediately after applet has loaded?

SharkD shared this question 2 years ago
Answered

I am reading this reference:


https://wiki.geogebra.org/e...


How do I execute one of these commands immediately after the applet is done loading? I tried applying the script to the ONLOAD parameter of the BODY object, but that apparently is too soon and I get an error.


Thanks.

Comments (9)

photo
1

I think that it's sufficient to add your command to the Global Javascript tab.

For example

function ggbOnInit(){ggbApplet.evalCommand('n=0')} 

sets the value of the (existing) slider n to 0 at file opening.

photo
1

I am trying to control the applet from the outside, for possibly many documents that are loaded into it. Is the GeoGebra Apps API still officially supported? It predates GeoGebra 5 (or 6 at least), and I have noticed strange behaviors when using the GeoGebra 6 program menus.

photo
1

I'm looping your question to the devs :)

photo
1

I have an HTML worksheet that reloads the applet each time I interact with most of the main hamburger menu items (for instance "Perspectives" or "View") and I don't understand why. Can I upload them here?

photo
1

Paste the link to your worksheet

photo
1

Try with the parameter appletOnLoad.


https://wiki.geogebra.org/e...

Example:

'appletOnLoad' = function() {

getInput();

calculate();

showOutput();

}

(Lesson received from Michael Borcherds)

photo
1

I seem to have something similar happening with the attached app. Upon loading, not all the scripts are running (setting rradius, sside, and aapothem values from randlength for example). However, after loading, clicking the New Exercise button, seems to make things work fine. The same SetValue scripts in randlength are that button.

Any help would be appreciated.

Thanks!

photo
1

Try this:


function ggbOnInit() {
    ggbApplet.evalCommand('RunClickScript(button2)');
}


The following method:

'appletOnLoad' = function() { }
is used only when the applet is embedded in an HTML script.

photo
© 2021 International GeoGebra Institute