Javascript New Window With Dynamic Content And Blank Url, Event Listeners Not Called
Case 1: var printWindow = window.open('', 'print_window'); if(printWindow) { printWindow.addEventListener('load', function(){alert(1);}, false); //Everything works but this l
Solution 1:
You've some document context problems. Have a look up to documentation and dummy examples for window.open.
Also inspect below snippet and give attention that how alert function should be called from different window namespace.
<!DOCTYPE html><html><head><title></title></head><body><buttonid="window_opener">Click me to load a new window</button><scripttype="text/javascript">document.getElementById("window_opener").addEventListener('click', function(){
var badDocumentString = "<html><head><title>print window</title></head><body>I live in child window</body></html>";
var child = window.open()
childdoc = child.document
childdoc.write(badDocumentString);
childdoc.close();
child.addEventListener("load", function(){
child.alert("zeee germans"); //attention here
});
})
</script></body></html>
Post a Comment for "Javascript New Window With Dynamic Content And Blank Url, Event Listeners Not Called"