JSFiddle - React, Tailwind, and code Playground
HTML
<button id="idview" type="submit">
Submit
</button>
JavaScript
var myWindow;
$("#idview").click(function() {
var vidurl = $('#vurl').val();
counter();
myWindow = window.open(vidurl, "popupWindow", "width=600, height=400, scrollbars=yes");
myWindow.onbeforeunload = function(){
console.log("Closed");
};
});
function counter() {
var n = $('.c').attr('id');
var c = n;
$('.c').text(c);
setInterval(function() {
c++;
if (c <= 41) {
$('.c').text(c);
}
if (c == 41) {
$('.c').text(n);
}
}, 1000);
}
setInterval(function() {
myWindow.close();
}, 45000);