Applet zu Applet Kommunikation, Listener
Ich möchte auf einer Webseite über Javascript den Wert einer Variablen von einem Applet auslesen und diesen Wert auf eine Variable in einem anderen Applet übertragen. Es funktioniert aber nur die manuelle Übertragung per Taste, nicht die über einen Listener. Dazu habe ich folgenden Code in HTML geschrieben:
In English:
On a website I want to read the value of a variable in a ggb-applet using javascript and pass this value to a second ggb-applet. This is my code:
<html>
<head>
<title>Applet to Applet</title>
<script type="text/javascript" src="https://www.geogebra.org/ap...;
<! ***************************************** -->
<script type="text/javascript">
var parameters1 = {
"id": "app1",
"width":500,
"height":200,
"mayscript":true,
"material_id":"ac9e6dyy"};
var applet1 = new GGBApplet(parameters1, true);
var parameters2 = {
"id": "app2",
"width":500,
"height":200,
"mayscript":true,
"material_id":"mvvtfdr8"};
var applet2 = new GGBApplet(parameters2, true);
window.onload = function() {
applet1.inject(applet_container1);
applet2.inject(applet_container2);
}
</script>
<! ***************************************** -->
<script type="text/javascript">
function ggbOnInit() { document.app1.registerObjectUpdateListener("a", "aListener"); }
function aListener(objName) {
var changedValue = document.app1.getValue(objName);
var b = "b";
document.app2.setValue(b, changedValue);
}
function uebertragen() {
var a = "a";
aListener(a);
}
</script>
</head>
<body>
Stelle zuerst a ein. <br>
Applet1<br> <div id="applet_container1"></div> <br>
Applet2<br> <div id="applet_container2"></div><br>
Manuell übertragen geht. Es sollte aber auch automatisch gehen, wenn man a verändert.<br><br>
<input value=" Manuell uebertragen " onclick="uebertragen();" type="button">
</body>
</html>
Hier kann man die Sache in (Nicht-)Aktion sehen:
You can see it here
http://s412533565.online.de...
Was mache ich falsch. Danke für jede Hilfe.
What is wrong. Thank you for any help.
Norbert
Try using appletOnLoad
https://test.geogebra.org/~...
Thank you, but this did NOT help. I found out, what it was:
In the parameters I need: "useBrowserForJS: true". Now it is working. This is my code now:
<script type="text/javascript">
var parameters1 = {
"id": "app1",
"width":500,
"height":200,
useBrowserForJS: true, // <-------------------------
"mayscript":true,
"material_id":"ac9e6dyy"};
var applet1 = new GGBApplet(parameters1, true);
Comments have been locked on this page!