javascript [removed] in new tab

前端 未结 7 694
失恋的感觉
失恋的感觉 2020-12-02 06:43

I am diverting user to some url through window.location but this url opens in the same tab in browser. I want it to be open in new tab. Can I do so with window.

7条回答
  •  情话喂你
    2020-12-02 07:13

    Rather going for pop up,I personally liked this solution, mentioned on this Question thread JavaScript: location.href to open in new window/tab?

    $(document).on('click','span.external-link',function(){
            var t               = $(this), 
                URL             = t.attr('data-href');        
            $('External Link')[0].click();
    
        });
    

    Working example.

提交回复
热议问题