Pop-up blocked error when opening url from outlook webaddin

◇◆丶佛笑我妖孽 提交于 2019-12-22 01:18:08

问题


i am trying to open url when user clicks on a button in plugin view. But web addin is throwing error.

My code to open 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);

Error message :

App is rejected from store because of this error. How can i overcome this error?

I don't want to use Dialogue API which doesnot open url in the browser.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/46562117/pop-up-blocked-error-when-opening-url-from-outlook-webaddin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!