一、原因:
1、因为在chrome的安全机制里面,非用户触发的window.open方法,是会被拦截的;

二、什么情况下不会被拦截或会被拦截?

1.

$('#btn').click(function () {
//不会被拦截
window.open(url)
});

2.

$('#btn').click(function () {
$.ajax({
url: 'xxxx.com',
success: function (url) {
//会被拦截
window.open(url);
}
})
}); 

分析原因:

用户没有直接发出window.open请求,而是发出一个ajax请求,window.open方法被放在了ajax的回调函数里,这样的情况就会被拦截了;

三、既然发现那就解决:

$('#btn').click(function () {
//打开一个不被拦截的新窗口
var newWindow = window.open();
$.ajax({
url: 'xxxx.com',
success: function (url) {
//修改新窗口的url
newWindow.location.href = url;
}
})
});//先在回调函数之前打开新窗口,后再加载url

最新文章

  1. c语言的学习秘籍之链表
  2. 声明replicated属性之后我编译不通过的问题
  3. maven 错误No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format
  4. Ping批量函数
  5. Linux命令行批量替换多文件中的字符串【转】
  6. delphi 完全控制Excel 文件
  7. C# 隐藏和覆盖
  8. (转)asp.net分页存储过程
  9. Tsung测试统计报告说明
  10. C#读书笔记之object类的基本方法
  11. python学习day16 模块(汇总)
  12. linux 使用不安全的sprintf函数,存储字符越界导致程序莫名崩溃问题
  13. oracle插入数据问题
  14. win系统 Mysql 5.7.19 zip 安装
  15. 树莓派进阶之路 (003) - Raspberry Pi(树莓派)国内软件源
  16. HBase写入性能及改造——multi-thread flush and compaction(续:详细测试数据)[转]
  17. Echarts 曲线数少于图例数解决方法
  18. Developing modules for the Apache HTTP Server 2.4
  19. codevs 3235 战争
  20. IO流-递归遍历目录下指定后缀名结尾的文件名称

热门文章

  1. Stone Game II
  2. Java编译器的优化
  3. 180908 input
  4. PHP中使用 Memcached 的测试案例
  5. docker使(二)—发布node应用镜像和容器
  6. Tkinter 之ProgressBar进度条标签
  7. [内网渗透]Mimikatz使用大全
  8. 怎么用switchhost
  9. rsync 使用ssh协议免密
  10. Python安装第三方库常用方法