【发布时间】:2018-05-30 02:56:02
【问题描述】:
当我在 Word Online 中关闭对话框时,我在控制台中收到以下消息:
Unknown conversation Id.
我没有得到一个我可以处理的代码,我只是得到那个......
(macOS / Chrome 版本 66.0.3359.181(官方构建)(64 位))
在 Word for Mac 16.13.1 (180523) 上运行的相同代码(从 localhost 和侧面加载的清单运行) - 构建速度慢 - 导致对话框窗口无法正常运行...关闭时它们不会触发我可以使用的代码并且 Javascript 似乎没有在其中运行。当我尝试检查对话框时,我得到一个疯狂的窗口闪烁并且控制台没有打开。
总体感觉 displayDialogAsync API 有问题。
这是一个创建对话框的示例 sn-p:
$('.integrateQuotes').click(function(){
console.log('Clicking quote machine choice...');
var dialogUrl = 'https://localhost/AnnotateX/qWord/modules/integratequotes.html';
var dialog = null; // dialogwindow object
Office.context.ui.displayDialogAsync(dialogUrl, {height: 80, width: 80, displayInIframe: true}, function (asyncResult){
dialog = asyncResult.value;
error = asyncResult.error;
status = asyncResult.status;
console.log('Result from dialog window...error: ') + + console.log(' and status: ') + console.log(status) + console.log(dialog);
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
});
});
self.location.href = '#writingDiv';
和进程消息:
function processMessage(arg) {
// var messageFromDialog = JSON.parse(arg.message);
// showUserName(messageFromDialog.name);
console.log('processing message from dialog: ') + console.log(arg);
// switch (arg.error) {
// case 12002:
// console.log("The dialog box has been directed to a page that it cannot find or load, or the URL syntax is invalid.");
// break;
// case 12003:
// console.log("The dialog box has been directed to a URL with the HTTP protocol. HTTPS is required."); break;
// case 12006:
// console.log("Dialog closed.");
// break;
// default:
// console.log("Unknown error in dialog box.");
// break;
// }
// dialog.close();
if (arg.message === 'easyBib'){
//Now open URL
var win = window.open('http://www.easybib.com/cite/results?source=website&provider=&cite-style=mla7&query=' + localStorage.easyBib);
console.log("Sending to easyBib: " + localStorage.easyBib);
if (win) {
//Browser has allowed it to be opened
win.focus();
} else {
//Browser has blocked it
alert('Please allow popups for this website');
}
} else {
dialog.close();
self.location.href = '#writingDiv';
}
// self.location.href = 'qResearch.html';
// window.location.replace("/qResearch.html");
// window.location.href = "/newPage.html";
}
我现在要在 Windows 上尝试...但是有些东西
【问题讨论】:
标签: javascript office-js