displayDialogAsync和html5-history-api的冲突 [英] Conflict of displayDialogAsync and html5-history-api
问题描述
我有一个 mean-stack
的应用程序,它托管一个网站和一个Excel加载项。 html5
已启用,且已
I have an application by mean-stack
that hosts a website and an Excel add-in. html5
is enabled, and it has
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<script src="https://cdn.rawgit.com/devote/HTML5-History-API/master/history.js"></script>
在Excel加载项中,我有一个按钮,可以通过 Dialog API :
In the Excel add-in, I have a button that opens a page in the website by Dialog API:
$scope.openDialog = function () {
Office.context.ui.displayDialogAsync("https://localhost:3000/preview/tmp/6wr-4PqdBrYQwjp3AAAD", {}, function () {})
}
当我在Chrome中点击Excel Online中的此按钮时,它会打开一个包含以下网址的对话框(请注意#
以及几个%系统地附加2F
,但它不能阻止良好地显示页面。
When I click on this button in Excel Online in Chrome, it opens a dialog box with the following url (note that #
and several %2F
are systematically appended), but it does not prevent from well displaying the page.
https://localhost:3000/preview/tmp/6wr-4PqdBrYQwjp3AAAD?_host_Info=excel|web|16.00|en-us|b6f37f78-e519-7d03-0069-b9c4317a362c|isDialog#%2Fpreview%2Ftmp%2F6wr-4PqdBrYQwjp3AAAD%3F_host_Info=excel%7Cweb%7C16.00%7Cen-us%7Cb6f37f78-e519-7d03-0069-b9c4317a362c%7CisDialog
然而,当我在Firefox中单击Excel Online中的此按钮时,网址会快速更改为以下网址,结果是显示网站的主页:
However, when I click on this button in Excel Online in Firefox, the url changes quickly to the following url, which turns out to display the homepage of the website:
https://localhost:3000/home#%2Fpreview%2Ftmp%2F6wr-4PqdBrYQwjp3AAAD%3F_host_Info=excel%7Cweb%7C16.00%7Cen-gb%7C919fff78-e51f-dc20-0c3c-871b7d0ec25d%7CisDialog
所以我的问题是:
1)为什么 Office.context.ui.displayDialogAsync
系统地添加#
和%2F
到我网站的网址?是否可以防止这种情况发生?
1) Why does Office.context.ui.displayDialogAsync
add systematically #
and %2F
to the url of my website? Is it possible to prevent this from happening?
2)是否可以制作网址(无论#
Firefox接受%2F
)?
2) Is it possible to make a url (regardless of #
and %2F
) that Firefox accept?
编辑1:似乎如果我不使用 html5-history-api
,它会起作用。所以不知道如何为那个 displayDialogAsync
禁用 html5-history-api
? (我必须在 office.js
之后使用 html5-history-api
的原因是这里。)
Edit 1: It seems that if I don't use html5-history-api
, it will work. So does not know how to disable html5-history-api
for that displayDialogAsync
? (The reason why I have to use html5-history-api
after office.js
is here.)
推荐答案
它不是 displayDialogAsync
这样做。这是Angular路由和Angular位置策略的常见问题。搜索有角度的应用程序正在添加哈希到我的网址,你会发现很多关于它和解决方案的信息。
It is not displayDialogAsync
that is doing this. It is a frequent issue with Angular routing and Angular location strategy. Search for "angular app is adding hash to my urls" and you will find a lot of information about it and solutions.
这篇关于displayDialogAsync和html5-history-api的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!