I need to open a pop up window that closes automatically after x seconds. This code works fine outside Sharepoint:
function openWin1() {
var myWindow1 = window.open("http://url here", "myWindow1", "width=500,height=400");
setTimeout(function(){myWindow1.close()}, 6000);
}
<button onclick="openWin1()"> Open "myWindow1"</button>
But when I add it to a SP Online publishing page, the "parent" page refreshes in the background - the pop up doesn't close.