-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_web_page.html
More file actions
26 lines (25 loc) · 1.09 KB
/
sample_web_page.html
File metadata and controls
26 lines (25 loc) · 1.09 KB
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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://thunkable.github.io/webviewer-extension/thunkableWebviewerExtension.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
// when we get a message from the app, display it on the page
ThunkableWebviewerExtension.receiveMessage(function(message) {
ThunkableWebviewerExtension.postMessage(message);
});
// when we get a message from the app that needs a return value
// return the string 'fast response' unless the message is
// 'slow message'. If the message is 'slow message', wait for
// four seconds, then return the string 'slow response'.
// The slow response shows how this could work for API calls that
// take time to execute.
ThunkableWebviewerExtension.receiveMessageWithReturnValue(function(message, callback) {
if (message === 'slow message') {
setTimeout(() => callback('slow response'), 4000);
} else {
callback('fast response');
}
});
</script>
</html>