Difference between revisions of "Reference:GeoGebra Apps Embedding"
(→Embed using Javascript: fix broken link) |
|||
Line 28: | Line 28: | ||
In the example the parameter 'showMenuBar:true' overrides the material setting from tube to show the menu bar for applet3. | In the example the parameter 'showMenuBar:true' overrides the material setting from tube to show the menu bar for applet3. | ||
+ | |||
+ | Add also: | ||
+ | <pre> applet1.setHTML5Codebase('https://app.geogebra.org/5.0/web3d/'); | ||
+ | applet2.setHTML5Codebase('https://app.geogebra.org/5.0/web3d/');</pre> | ||
+ | |||
+ | In case you are using the Math Apps Bundle, please use | ||
+ | <pre> applet1.setHTML5Codebase('GeoGebra/HTML5/5.0/web3d/'); | ||
+ | applet2.setHTML5Codebase('GeoGebra/HTML5/5.0/web3d/');</pre> | ||
{{Step|num=3}} Finally, you need to determine where the applet should appear in the document and inject the applet. In our example file we create a div as parent for each applet, like this: | {{Step|num=3}} Finally, you need to determine where the applet should appear in the document and inject the applet. In our example file we create a div as parent for each applet, like this: |
Revision as of 04:43, 17 July 2016
GeoGebra API Documentation
This article describes how to embed GeoGebra Math Apps into your website or offline HTML materials using Javascript.
Location of Math Apps
You can use Math Apps from our CDN (app.geogebra.org) or you can download them as Math Apps Bundle that you can host on your own server or use offline.
Embed using Javascript
This method is recommended when multiple HTML5 applets are embedded in one page, or if you need to use the JavaScript API. In this case they can share one instance of the GeoGebra codebase and load faster. Here is an example web page that shows how to embed applets: Example page.
You need to include the following three parts in your HTML file:
1 The javascript library deployggb.js needs to be included with this tag:
<script src="https://www.geogebra.org/scripts/deployggb.js"></script>
In case you are using the Math Apps Bundle, please use
<script src="GeoGebra/deployggb.js"></script>
2 For each applet a javaScript object of the type GGBApplet needs to be created. It takes at least the material ID from tube as a parameters.
Here is the according code from the example page that creates 2 applets:
var applet1 = new GGBApplet({material_id: "17499", borderColor:"#55FF00"}, true); var applet2 = new GGBApplet({filename: "../ggb/sine-curves.ggb","showtoolbar":true}, true);
The above example shows how to load a file using the filename or the id of the material on GeoGebra Materials Platform. For offline use you will need to specify the file using a base64 encoded string.
When used with the id parameter, the applet will be created using the dimensions (width and height) and the applet parameters defined in the material settings on GeoGebra Materials Platform. Optionally you can override these settings by passing them in the parameters. See Reference:Applet_Parameters for a list of applet parameters.
In the example the parameter 'showMenuBar:true' overrides the material setting from tube to show the menu bar for applet3.
Add also:
applet1.setHTML5Codebase('https://app.geogebra.org/5.0/web3d/'); applet2.setHTML5Codebase('https://app.geogebra.org/5.0/web3d/');
In case you are using the Math Apps Bundle, please use
applet1.setHTML5Codebase('GeoGebra/HTML5/5.0/web3d/'); applet2.setHTML5Codebase('GeoGebra/HTML5/5.0/web3d/');
3 Finally, you need to determine where the applet should appear in the document and inject the applet. In our example file we create a div as parent for each applet, like this:
<div id="applet_container1"></div>
At the end of the script section the applets are injected to this divs using the inject function:
window.onload = function() { applet1.inject('applet_container1', 'preferHTML5'); applet2.inject('applet_container2', 'preferHTML5'); applet3.inject('applet_container3', 'preferHTML5'); }
The parameters of the method inject()
are:
Parameter | Description |
---|---|
containerID | A string with the id of the HTML object that will be the parent of the applet. |
appletType | This can be one of the following keywords:
Other values are deprecated. |
Examples
- Single applet
- Single applet 3D
- Two applets
- Single applet + API
- Two applets + API
- Single applet + API
- Apps with toolbar
- Event listeners
- Communication between applets
- Exercise
es:Referencia:Applet Embebido fr:Référence:Appliquettes_imbriquées it:Riferimenti:Incorporare_Applet