-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
35 lines (25 loc) · 889 Bytes
/
index.html
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
<!doctype html>
<html lang="en-us">
<button class="mybutton1">Run myFunction</button>
</html>
<script async type="text/javascript" src="main.js"></script>
<script type='text/javascript'>
function finished() {
alert('finished');
}
function back(text){
alert(Pointer_stringify(text));
}
window.addEventListener('message', function (e) {
//e.source.postMessage(e.data + " message");
alert (e.data + ' message');
});
document.querySelector('.mybutton1').addEventListener('click', function()
{
alert('before async');
var pointer = Runtime.addFunction(back);
Module.ccall ('async', null, 'pointer', [pointer], { async: true });
//Runtime.removeFunction(pointer);// Do not call removeFunction becuase after 20 sec. js cannot fint callback. into main.cpp - function onMessage.
alert('after async');
});
</script>