Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从jQuery回调中打开新的浏览器选项卡_Javascript_Jquery_Html_Ajax - Fatal编程技术网

Javascript 如何从jQuery回调中打开新的浏览器选项卡

Javascript 如何从jQuery回调中打开新的浏览器选项卡,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,为了实现这一目标,我尝试了以下方法: 但是在调用窗口时这两种方法都不起作用。请从回调内部打开。这是我的密码 $.post('api', { }, function() { var win = window.open('target-file', '_blank'); win.focus(); }); 用窗口的名称试试看 像 使用MySurfaceWindow=window.open(“url”、“windowname”、“settings”) 请参见以

为了实现这一目标,我尝试了以下方法:

但是在调用
窗口时这两种方法都不起作用。请从回调内部打开
。这是我的密码

$.post('api', { 
    }, function() {
    var win = window.open('target-file', '_blank');
    win.focus();
    });

用窗口的名称试试看


使用
MySurfaceWindow=window.open(“url”、“windowname”、“settings”)
请参见以下示例:

MySurfaceWindow = window.open('/DesktopModules/DMS/DMS.PatientEChart/Surface Pages/Surface6.aspx?SurfaceTooth=' + $("#lbl" + $(this).val()).text() + '&ProcedureID=0' + '&ColorD=I' + '', '', 'height=240,width=200,top=' + top + ',left=' + left + 'status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no');
试试这个:

 $.post('api', { 
    }, function() {
    window.open('target-file', '_blank');
   });

您可以将这个简单的jQuery snipplet添加到源代码中,以在web浏览器的新选项卡中打开每个外部链接

$(document).ready(function(){
  $('a').each(function() {
    var a = new RegExp('/' + window.location.host + '/');
    if(!a.test(this.href)) {
      $(this).click(function(event) {
        event.preventDefault();
        event.stopPropagation();
        window.open(this.href, '_blank');
      });
    }
  });
});

新窗口可能被弹出窗口拦截器阻止?可能重复
$(document).ready(function(){
  $('a').each(function() {
    var a = new RegExp('/' + window.location.host + '/');
    if(!a.test(this.href)) {
      $(this).click(function(event) {
        event.preventDefault();
        event.stopPropagation();
        window.open(this.href, '_blank');
      });
    }
  });
});