'ggbApplet is not defined' javascript 中的错误
'ggbApplet is not defined' error in javascript
我有一个包含 geogebra 小程序的网页。在加载页面时,我想根据用户输入修改小程序中的某些元素。我测试了以下代码
<script type="text/javascript">
var parameters = {
"width":600,"height":450,
"filename":"trois_ensembles.ggb"};
var applet = new GGBApplet('5.0', parameters);
window.onload = function() {
applet.inject('applet_container');
ggbApplet.setVisible('A', false);
}
</script>
但是行
ggbApplet.setVisible('A', false);
在控制台中产生错误
ReferenceError: ggbApplet is not defined
当 ggbApplet
在别处引用时,如
<button onclick="ggbApplet.setVisible('A', true)">Set A </button>
一切正常。
我不明白 ggbApplet
的范围。帮助表示赞赏。
检查 Geogebra 维基 Scripting 页面的 全局 JavaScript 部分可能会有用。
干杯。
查看此部分:
Note: Using any ggbApplet methods in Global JavaScript outside of ggbOnInit will not work as intended since they will be called before the construction is loaded.
我有一个包含 geogebra 小程序的网页。在加载页面时,我想根据用户输入修改小程序中的某些元素。我测试了以下代码
<script type="text/javascript">
var parameters = {
"width":600,"height":450,
"filename":"trois_ensembles.ggb"};
var applet = new GGBApplet('5.0', parameters);
window.onload = function() {
applet.inject('applet_container');
ggbApplet.setVisible('A', false);
}
</script>
但是行
ggbApplet.setVisible('A', false);
在控制台中产生错误
ReferenceError: ggbApplet is not defined
当 ggbApplet
在别处引用时,如
<button onclick="ggbApplet.setVisible('A', true)">Set A </button>
一切正常。
我不明白 ggbApplet
的范围。帮助表示赞赏。
检查 Geogebra 维基 Scripting 页面的 全局 JavaScript 部分可能会有用。
干杯。
查看此部分:
Note: Using any ggbApplet methods in Global JavaScript outside of ggbOnInit will not work as intended since they will be called before the construction is loaded.