JSFiddle - React, Tailwind, and code Playground

by josh3736

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>
<p><a id="inc" href="#">Increment counter in secondary window</a></p>

JavaScript

var win2;

function openSecondaryWindow() {
    return win2 = window.open('/josh3736/Wm4nT/show', 'secondary', 'width=300,height=150');
}

function flash() {
    $('body').css('background-color', 'red').animate({
        'background-color': '#fff'
    });
}

$(function() {

    if (!openSecondaryWindow()) $(document.body).prepend('<a href="#">Popup blocked.  Click here to open the secondary window.</a>').click(function() {
        openSecondaryWindow();
        return false;
    });

    $('#inc').click(function() {
        if (win2) win2.increment();
        else alert('The secondary window is not open.');
        return false;
    });
});