JSFiddle - React, Tailwind, and code Playground

HTML

<button id="open">open</button>
<button id="focus">focus</button>

JavaScript

var w;

function PopupDelete(delete_images) {
    w = window.open('/testing/t/', 'PopupDelete', 'width=500,height=400,scrollbars=yes');
    console.log(w);
    if(w){
    w.focus();
    }
}

$(function () {
    PopupDelete();
    
    $('#open').click(PopupDelete);
    $('#focus').click(function () {
        console.log('f', w);
        w.focus();
    });
});