What's the best way to open new browser window?

前端 未结 10 1313
一生所求
一生所求 2021-01-30 03:06

I know that most links should be left up to the end-user to decide how to open, but we can\'t deny that there are times you almost \'have to\' force into a new window (for examp

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 03:51

    I use this...

    $(function() {
      $("a:not([href^='"+window.location.hostname+"'])").click(function(){
        window.open(this.href);
        return false;
      }).attr("title", "Opens in a new window");
    });
    

提交回复
热议问题