从Outlook Webaddin打开URL时弹出窗口阻止错误 [英] Pop-up blocked error when opening url from outlook webaddin
问题描述
我试图在用户单击插件视图中的按钮时打开url.但是网络插件引发错误.
i am trying to open url when user clicks on a button in plugin view. But web addin is throwing error.
我打开url的代码:
let a = document.createElement("a");
a.setAttribute('target', '_blank');
a.setAttribute("style", "display: none");
document.body.appendChild(a);
a.href = finalUrl;
a.click();
document.body.removeChild(a);
错误消息:
由于此错误,应用被从商店拒绝.我该如何克服这个错误?
App is rejected from store because of this error. How can i overcome this error?
我不想使用在浏览器中无法打开url的Dialogue API.
I don't want to use Dialogue API which doesnot open url in the browser.
推荐答案
一般规则是,打开窗口不是用户操作的直接结果时,始终会被阻止.有关更多信息,请参见以下SO问题:避免浏览器弹出窗口阻止程序.
The general rule is opening a window will always be blocked when it isn't the direct result of a user action. For more information, see this SO question: Avoid browser popup blockers.
您正在触发一个弹出窗口,因为您试图模拟click()
.由于这不是直接的用户操作,因此所有主流浏览器都将标记此操作.
You're triggering a popup because your attempting to emulate a click()
. Since this is not a direct user action, this action will get flagged by all mainstream browsers.
您需要向用户展示可点击的元素(链接,按钮等),以打开一个新窗口.
You will need to present the user with a clickable element (link, button, etc) that opens a new window.
这篇关于从Outlook Webaddin打开URL时弹出窗口阻止错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!