问题
With the newest update to Word (1611) dialogs with TinyMCE causes error 12003: Invalid URL Syntax.
According to Use the Dialog API the cause is
The dialog box was directed to a URL with the HTTP protocol. HTTPS is required.
Simple example is to put below code in a dialog (oddly enough it works in a panel).
Updated code
<!DOCTYPE html>
<html>
<head>
<title>Office.js with TinyMCE</title>
<meta charset="utf-8" />
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdn.tinymce.com/4/tinymce.min.js"></script>
<script type="text/javascript">
(function () {
"use strict";
// The initialize function must be run each time a new page is loaded.
Office.initialize = function (reason) {
$(document).ready(function () {
tinymce.init({ selector: 'textarea' });
});
};
})();
</script>
</head>
<body>
<textarea></textarea>
</body>
</html>
Edit1: This is only a problem on Windows. On Mac it works fine.
Edit2: The code for opening the dialog
var url = 'https://' + location.host + '/dialog.html';
console.log('url: ' + url); // url: https://localhost:44341/dialog.html
Office.context.ui.displayDialogAsync(url, { height: 30, width: 20 });
回答1:
We've identified the issue. Turns out we are blocking the javascript: URL protocol which seems to be invoked when using TinyMCE. We are working on a fix.
回答2:
12003 usually indicates you don't have https on your dialog url. This issue is more likely raised when displayDialogAsync is called, you are passing a HTTP url in the first argument.
For your html page with TinyMCE, I am able to copy-paste the entire html and open it in Office dialog. Therefore it is unlikely related to the tinyMCE.
(It will be much helpful you could share your code opening up the dialog.)
Best Regards
来源:https://stackoverflow.com/questions/41164617/dialog-with-tinymce-causes-error-12003