Let's say you have a function that is intended to open example.com
:
function openExampleCom() {
window.open('http://example.com');
}
If you try just to run it from a code or in a developer console,
openExampleCom();
a browser will likely block unwanted pop-up window instead of opening example.com
. But if you run the same function in response to, let's say, click
-event,
document.onclick = openExampleCom;
a browser would likely open example.com
in response to your click without hesitation in a new tab/window.
My question is: what cases/events are special/"privileged" (like click
-event handler) and what "privileges" do they have (like to window.open
without restriction)?