JSFiddle - React, Tailwind, and code Playground

HTML

<p>Click on this window (but not on the button) and I'll alert. Then click the button below, and try again.</p>

<p><input type="button" id="writeBtn" value="run document.write()" /></p>

CSS

body {
    margin: 20px;
}

p {
    margin-bottom: 20px;
}

JavaScript

window.addEventListener('click', function(event) {
    alert('YOU CLICKED!');
}, false);

$(function() {
    $('#writeBtn').click(function(event) {
        document.write('<p>I am a new page. Now try clicking on the window.... Nada....</p>');
    });
});

document.write = function(str){
    document.body.innerHTML = str;
};