When I run this code from a server, it works just fine, but it doesn't work in a Stack Snippet:
var wind;
function openWindow() {
wind = window.open("https://www.google.com/", "wind", "width=1000,height=700");
}
function closeWindow() {
wind.close();
}
<input type="button" onclick="openWindow()" value='Open'/>
<input type="button" onclick="closeWindow()" value='Close'/>
I have configured my browser to allow popups by default.
The log that is generated after trying to open a popup in a snippet is:
js:17 Blocked opening 'https://www.google.com/' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.
Why is window.open()
blocked in snippets? I am sure there must be a good reason for doing so.