TAG
JavaScript
Result
Run
License
<button type="button" id="btn-openwin">Open New Window</button>
window.addEventListener("load", function() { var btnOpenWin = document.querySelector("#btn-openwin"); btnOpenWin.addEventListener("click", function() { var newWin = window.open("", "", "width=400,height=300"); var btnClose = document.createElement("button"); btnClose.textContent = "Close"; btnClose.addEventListener("click", function() { this.ownerDocument.defaultView.close(); }); newWin.document.body.appendChild(btnClose); }); });
Console
expand_less
License
License
by DevDic
Close