GGB数学云 GGB+JS样例9 - 保存和还原

GGB+JS样例9 - 保存和还原

2016年11月22日 人阅读 GeoGebra»GGB+JS样例

摘要: 本文介绍基于GeoGebra和JavaScript的小程序样例 - 保存和还原GGB文件。

网页代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>保存和还原GGB文件</title>
</head>
<body>
<button id="save">保存</button>
<button id="restore">还原</button>
<div id="applet"></div>
<textarea readonly placeholder="保存后将显示内容"></textarea>
<script src="http://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
<script src="../GeoGebra/deployggb.js"></script>
<script>
var base64;
var applet = new GGBApplet({ showToolbar: true, width: 500, height: 400 });
applet.setHTML5Codebase('../GeoGebra/HTML5/5.0/web/', true);
window.onload = function() {
applet.inject('applet', 'html5');
};
$('#save').click(function() {
ggbApplet.getBase64(function(content) {
base64 = content;
$('textarea').text(content);
});
});
$('#restore').click(function() {
if (base64) {
ggbApplet.setBase64(base64);
}
});
</script>
</body>
</html>
分享到: 更多