Javascript Bring window to front if already open in window.open?

后端 未结 8 667
别那么骄傲
别那么骄傲 2020-11-30 07:35

If you open a window like:

window.open (\"url\",\"winName\",\"location=0,width=300,height=214\");

If winName is already open i

8条回答
  •  遥遥无期
    2020-11-30 07:58

    I had the same problem, have spent a lot of time to find a solution, finally it works by this:

    var singleWindow;
    function openNewWindow(){
    	if(singleWindow){
    		singleWindow.close();
    	}
    	singleWindow = window.open ("url","winName","location=0,width=300,height=214");
    }
    This close the current window (if exist) and open a new window that will be placed on the top (default behavior)

    Hope this help you !

提交回复
热议问题