forked from madhavagrawal17/DialogApi
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDialog.html
More file actions
56 lines (52 loc) · 1.75 KB
/
Dialog.html
File metadata and controls
56 lines (52 loc) · 1.75 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<title>JSOM DCR Test</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/beta/hosted/office.debug.js"></script>
<script type="text/javascript">
var _OM;
window.Office.initialize = function (reason) {
//_OM = Office.context.document;
text.value = "test test";
RegisterMessageChild();
}
function SendMessagetoParent() {
var value = document.getElementById("TxtData").value;
if (!value) {
value = "Hello";
}
Office.context.ui.messageParent(value);
}
function RegisterMessageChild() {
Office.context.ui.addHandlerAsync(Office.EventType.DialogParentMessageReceived, onMessageFromParent, onRegisterMessageComplete);
}
function onMessageFromParent(event) {
messsageFromDialog.value += event.message;
}
function onRegisterMessageComplete(asyncResult) {
text.value += asyncResult.status;
if(asyncResult.status != Office.AsyncResultStatus.Succeeded) {
text.value += asyncResult.error.message;
}
}
</script>
<script>
// Perform Step 2 of an initialization that -- in a real developer scenario (non-test-agave), would have
// been included inside the "excel-web-16.00.js"/"excel-win32-16.01.js"/etc files
Office.onReady(function(info) {
// do something
});
</script>
</head>
<body>
<div>
Message
<div>
<button id="BtnSetData" onclick="SendMessagetoParent()">SendMessageToParent</button>: <input id="TxtData" type="text" />
</div>
</div>
<textarea id="text" cols="20" rows="5"></textarea>
<textarea id="messsageFromDialog" cols="20" rows="5"></textarea>
</body>
</html>