问题
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