gpt4 book ai didi

javascript - Word Online 中的 displayDialogAsync 未记录与 Word Online 到 Word for Mac 不同的关闭操作/损坏行为

转载 作者:行者123 更新时间:2023-12-03 01:47:13 28 4
gpt4 key购买 nike

当我关闭 Word Online 中的对话框时,我在控制台中收到以下消息:

Unknown conversation Id.

我不是得到一个可以处理的代码,而是得到......

(macOS/Chrome 版本 66.0.3359.181(官方版本)(64 位))

在 Word for Mac 16.13.1 (180523) 上运行的相同代码(从本地主机和旁加载 list 运行) - 构建缓慢 - 导致对话框窗口无法正常运行...关闭时它们不会启动我可以使用的代码,并且 Javascript 似乎无法在其中运行。当我尝试检查对话框时,窗口剧烈闪烁,并且控制台无法打开。

总体感觉 displayDialogAsync API 有问题。

这是一个示例对话框创建片段:

$('.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 上尝试...但是有些事情

最佳答案

要处理用户关闭对话框的事件,您需要 DialogEventReceived 事件的处理程序,而不是 DialogMessageReceived。更多信息请访问:Using a Dialog with Office Add-ins .

关于javascript - Word Online 中的 displayDialogAsync 未记录与 Word Online 到 Word for Mac 不同的关闭操作/损坏行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50589500/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com