I would do so - basically storing all referenced opened windows in the function itself. When the function fires, check if the window does not exist or has been close - from that, start the pop-up window. Otherwise, focus on the existing popup for that request.
function launchApplication(l_url, l_windowName)
{
if ( typeof launchApplication.winRefs == 'undefined' )
{
launchApplication.winRefs = {};
}
if ( typeof launchApplication.winRefs[l_windowName] == 'undefined' || launchApplication.winRefs[l_windowName].closed )
{
var l_width = screen.availWidth;
var l_height = screen.availHeight;
var l_params = 'status=1' +
',resizable=1' +
',scrollbars=1' +
',width=' + l_width +
',height=' + l_height +
',left=0' +
',top=0';
launchApplication.winRefs[l_windowName] = window.open(l_url, l_windowName, l_params);
launchApplication.winRefs[l_windowName].moveTo(0,0);
launchApplication.winRefs[l_windowName].resizeTo(l_width, l_height);
} else {
launchApplication.winRefs[l_windowName].focus()
}
}
from : https://www.generacodice.it/es/articolo/191665/JavaScript+window.open+only+if+the+window+does+not+already+exist
沒有留言:
張貼留言