how to prevent reopening new window using jQuery?

后端 未结 2 1185
醉酒成梦
醉酒成梦 2020-12-11 06:05

I\'ve recently posted a new question in How jQuery can prevent reopening a new window?. At that post, I mentioned to my need for something on F2 key.
No

2条回答
  •  不思量自难忘°
    2020-12-11 07:04

    You can try this, it will help you to open and observe multiple windows, check here

    Javascript

    var windows = {};
    $('a').click(function(e){
        var url = $(this).attr('href');
        var name = $(this).attr('id');
        if(windows.hasOwnProperty(name) && !windows[name].closed ) 
        {
           windows[name].focus();   
        }
        else  
        {
           windows[name]=window.open (url,name,"status=1,width=300,height=300");
        }    
    });
    

    Your Links

    Google
    Yahoo

    DEMO.

提交回复
热议问题