谷歌拦截window.open()解决办法

window.open() 被拦截的问题解决 某些浏览器(比如Chrome)出于安全和体验的考虑,会禁止直接在JS中使用 window.open(url) 打开新的窗口。但是如果使用 `window.open(url,'_self') ` 改变当前窗口是允许的。 禁止直接打开的原因就是非用户操作产生的新弹出窗口,会被认为这可能是一个广告,所以禁止了这种行为。 阅读详情
$('.Doctor').on('click','.PaperT',function(){
            var STUId=$(this).parents('tr').attr('class')
            var newTab=window.open('about:blank');
            $.ajax({
                type : "POST",
                url  : "/look_pdf_file/",
                traditional: true,
                data : {"Id":STUId},
                dataType : 'json',
                cache : false,
                success : function(result) {
                    newTab.location.href=result.PDF.path_paper;
                }
            })
        })

 

未经测试

最终解决办法:浏览器设置

详解window.open被浏览器拦截的解决方案 现象 最近在做项目的时候碰到了使用window.open被浏览器拦截的情况,搞得人无比郁闷啊,虽然在自己的环境可以对页面进行放行,但是对用户来说,不能要求用户都来通过拦截。何况当出现拦截时,很多小白根本不知道发生了啥,不知道在哪里看被拦截的页面,简直悲催啊~~。 另外,可以发现,当window.open为用户触发事件内部或者加载时,不会被拦截,一旦将弹出代码移动到ajax或者一段异步代码内部,马上就出现被拦截的表现了。 原因分析&深入研究 当浏览器检测到非用户操作产生的新弹出窗口,则会对其进行阻止。因为浏览器认为这不是一个用户希望看到的页面。 比如对js中直接执行的,如下代码: js code 立即下载

相关推荐

从原理到实现:在《图灵完备》中构建一个144*256像素、1536时钟刻/帧的视频播放器

本文详细解析了在《图灵完备》游戏中构建144*256像素、1536时钟刻/帧视频播放器的全过程。从图灵完备原理出发,通过分层架构设计、视频数据预处理和关键电路实现,展示了如何用基础电子元件模拟现代显卡功能。重点介绍了像素坐标定位系统和颜色数据处理流水线的优化方案,为游戏内复杂电子系统设计提供实践指导。

weixin_42520025的博客 445

window.open链接跳转新窗口,谷歌不生效

点击后端返回的非本系统的网络链接并跳转,要求在新页面打开。如果是本标签打开直接window.location.href ="/url"。但是现在要求新标签页,window.open有浏览器限制。

qq_59626859的博客 1269

新版MQL语言程序设计:用vscode编写编译调试mt4和mt5程序

使用VScode搭建MT4与MT5开发环境,实现编辑编译调试统一。

超哥量化的博客 6872

window.open()在使用谷歌浏览器Chrome打开下载链接时页面一闪而过没有执行下载

原因 链接使用了http://导致被浏览器拦截 解决方案 使用 https:// 解决

qq_41784169的博客 4921

AD20/Altium designer——元器件批量命名与编号的高效技巧

本文详细介绍了在AD20/Altium Designer中实现元器件批量命名与编号的高效技巧。通过解析核心的“原理图标注”功能,从基础全局操作到进阶的按模块分区、利用标识符及合并BOM等智能方法,帮助硬件工程师彻底告别手动编号,大幅提升设计效率与文档规范性,并融入了一套完整的实战工作流。

whisky的博客 568

LSTM模型 轨迹经纬度预测

原始时间序列数据如下所示,我们只取前两列纬度和经度作为输入数据 我们设定用前六个位置信息预测下一个位置,则两个样本的输入输出数据如下所示: 创建LSTM网络训练模型: import numpy as np from keras.layers.core import Dense, Activation, Dropout from keras.layers import LS...

Muzi_Water的博客 2万+

解决某些浏览器(例如谷歌)window.open(url)无效问题

在项目中需要用到预览功能,一开始采用window.open(url)直接打开链接进入预览界面,但是在谷歌浏览器中不生效,网上查了一下相关问题,原因总结有两点: 在ajax请求的回调函数中window.open(url)是不生效的 (尝试在回调函数外面调用window.open(url),还是不行,坑) window.open(url)在用户操作事件中才能生效,否则浏览器判定该操作不是用户操作,会阻止窗口弹出。 (这个比较靠谱) 但是预览的URL是通过ajax请求得到的,倒是可以增加一个预览按钮绑定点击事件

u012211003的博客 8205

Vue集成飞书前端JSSDK

文章目录前言<1>飞书前端JSSDK<2>使用步骤1.将JSSDK引入到VUE2.读入数据总结 前言 公司需要使用飞书软件,所以转战飞书开发,也是对新知识的探索与研究,飞书SDK也一直都在更新,路虽远,行必达。 <1>飞书前端JSSDK 1、官网地址:https://open.feishu.cn/document/uYjL24iN/uITO4IjLykDOy4iM5gjM 2、当前使用的飞书前端JSSDk的版本:1.5.4 <!-- 在html文档中 --&gt

A 1万+

window.open()在谷歌浏览器不支持问题

项目需求:点击某个按钮弹出一个小窗 选取方法:window.open()  具体文档可以查看w3c 遇到的问题 按照文档的参数进行设置了宽高,发现弹出的小窗并没有改变,检查了resizable=true是没有问题的,于是又在360浏览器打开,咦,发现小窗的宽和高是改变了的,所以,一定是浏览器的兼容性问题,经过查找资料得出了以下结论: 在谷歌浏览器中top,left,width,hei...

chaitong2204的博客 1万+

Buck-Boost电路

前面我们学习了降压的Buck电路 (左图) 和升压的Boost电路 (右图),那么如果我们把Buck电路和Boost电路结合一下会发生什么情况? 我们尝试着画一下: 我们用Buck电路作为输入,然后用Boost电路进行调整,最后输出。因此Buck电路中的负载、Boost电路的电源都可以删掉。得到下图: 由于Buck电路中的C2的作用是在输出的时候滤波,这个功能已经由Boost电路中的C1实现了,因此可以删除Buck电路中的C2电容。得到下图: 这里两个电感处于串联状态,可以合二为一,得到下面的电路:

wangeil007的博客 4万+

某智能物流无人值守系统 ExportReport SQL注入漏洞复现

某智能物流无人值守系统 ExportReport存在SQL注入漏洞,未经身份验证的远程攻击者除了可以利用 SQL 注入漏洞获取数据库中的信息(例如,管理员后台密码、站点的用户个人信息)之外,甚至在高权限的情况可向服务器中写入木马,进一步获取服务器系统权限。

0xSec 818

使用window.open打开新窗口被谷歌浏览器拦截

在写后台动态传前台资源链接的时候,需要用到,返回后直接在新窗口打开。开发使用的谷歌浏览器,使用window.open(),测试的时候,发现总是被拦截,这这里记录下解决的方法。 找了写资料,说是当非用户触发的window.open()方法时,由于谷歌的安全机制,通常是会被拦截的,除非人工取消拦截。比如下面两个例子:当用户没有直接发出window.open()请求的时候,不是直接调用,而是在回调函数...

hongyuancao的博客 6812

2026年数学建模国赛论文排版规范:Word与LaTeX终极对比及模板

提前演练:不要等到比赛开始才第一次使用排版工具。至少在赛前一个月完成1-2篇模拟论文的全流程排版练习。建立检查清单:基于国赛规范制定排版检查清单,在提交前逐项核对——公式编号连续?图表引用准确?参考文献完整?页数不超限?善用模板但不止于模板:模板提供的是起点而非终点。根据自身需求调整宏包配置和样式参数,理解每一行配置的含义。关注评审体验:从评委的视角审视论文——重点内容是否突出?逻辑结构是否清晰?视觉层次是否合理?备份与容错:无论使用何种工具,建立多级备份机制。本地、云端、U盘各存一份,且定期保存历史版本。

YOLO 210

ajax请求window.open()被拦截

项目使用ajax post后根据返回的success,需要打开一个新页面,使用window.open发现谷歌浏览器直接被拦截。 后来了解发现该操作并不是用户主动触发的,所以它认为这是不安全的就拦截了,即使 ajax 回调函数中模拟执行 click 或者 submit 等用户行为(trigger('click')), 浏览器也会认为不是由用户主动触发的,因此不能被安全执行,所以也会被拦截。废话不...

weixin_30859423的博客 171

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

window.open()打开文件下载链接被Google Chrome拦截问题

由于线上是https的链接,而window.open()打开的链接用的都是http。所以本地一直没问题,而线上存在问题。自己测试发现本地127.0.0.1是没有问题的,而连接线上虽然能够下载,但是有明显的提示“无法安全的下载”,需要再次确认才能下载。本次排查一直以为是window.open()的锅,绕了弯路。(因为我们下载链接是OSS含有时效性的链接都是后台生成返回的,所以调整一个接口就完事了)但是这回浏览器控制台有了明显的提示。按照此方法试了下,不能本次解决问题。试了多种方法后都没有效果。

lxw1844912514的博客 1558

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

window.open打开新窗口被浏览器拦截的处理方法

在平时开发中跳转新页面是我们经常遇到的,超链接直接跳转我们可以通过 <a href="http://www.tiaozhuan.com"></a> //或者 <a href="javascript:void(0)" onclick="window.open("www.tiaozhuan.com")"></a> //来跳转 如果在跳转之前我们需要先进行一系列的逻辑操作,那我们一般是用window.open('url')来跳转 function t

github_39237934的博客 1733

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ajax回调时浏览器拦截window.open()

现象:如下代码在window.open() 时会被浏览器拦截。 经测试,在直接open时,chrome51、firefox51、IE11 均不会拦截; 在有ajax请求回调后,这三个浏览器均会拦截。 $.ajax({ type: "POST", url: REQUEST_BASE_PATH + "/**", data: {

BigOrange的博客 1728

浏览器window.open()用法,以及利用其实现拦截弹出式窗口

浏览器window.open()用法,以及利用其实现拦截弹出式窗口 window.open('url','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no')

从事前端,不断积累经验,学习新的技术。头像不是本人是莉莉崽(美貌、可爱集于一身的小姐姐,小仙女),一个宝藏博主,值得喜欢! 6118

ajax请求回调后window.open()弹窗被拦截解决办法

代码示例:这里需要注意,现在的浏览器默认设置是,window.open()方法只能在click事件的程序线程中执行。 也就是必须触发click事件,如果事件中用ajax之类,就必须是同步模式。让代码都在同一个线程中执行。 异步模式会开启一个新的线程,就不能执行window.open()了 如果是这种模拟器方式打开新窗口,代码示例: 即使ajax请求设置了同步,会产生的效果:QQ浏览器正常打开,...

qq_36217060的博客 1013

ajax无法open,ajax中打开新页面使用window.open方法被拦截的解决方法

$('.testA').unbind('click').bind('click',function(){var result="";$.ajax({url:'http://localhost/demo/windowopen/test.php','type':'POST',async:false,dataType:'json',success: function(data){if(data &amp...

weixin_39902598的博客 877

解决window.open被浏览器拦截

其他的 方法都可以在别处找到,我今天说的是在ajax中window.open被拦截, 由于试了其他方法在谷歌和火狐成功了但是在360依然被拦截, 此时突然想到把ajax改为同步。然而成功了 async:false; ...

qq_38394249的博客 715

window.open被浏览器拦截

window.open被浏览器拦截 解决办法 一般被拦截,都是ajax请求后使用window.open造成的 我们可以把window.open 放到ajax的外面, let box = window.open('about:blank',"_self") $.ajax().then(res=&gt;{ box.location = res // 我这个实例是用下载的 }) 更多window....

齐枫的博客 772

解决window.open()在异步请求中页面被拦截问题

当我们在ajax异步请求的成功回调函数中使用 window.open("url", "_blank") 时,新开的窗口会被拦截,在谷歌、IE浏览器中会有拦截提示,但在360中提示很弱,基本不能发现,我们不能奢求每一个用户在使用的时候都通过浏览器设置允许拦截来让页面正常打开,所以只能想办法通过代码进行控制。 下面,我总结了我认为相对比较好的两种方法。 方法一:将ajax请求设置为同步请求 $...

Dancy的博客...... 5262

【转】window.open被浏览器拦截后的自定义提示

【转自】http://www.aoao.org.cn/blog/2007/11/window-open/ 现在越来越多的浏览器有拦截弹出窗口的功能。广告弹出来给拦掉了就无所谓,要是客户在付款时给拦掉了可就不能乱算了。 Gmail的“哎呀”算是经典,可是,前天心云给出了更帅的提示=。= 记得打开浏览器拦截后 测试一下,在线阅读器里不知道代码会不会给过滤。。代码在下边,...

dishuangqing3232的博客 160

input跳转链接_关于js页面window.open跳转新窗口被拦截解决

点击上方“蓝字”,发现更多精彩。window.open为什么被拦截部分浏览器默认不允许脚本方式去跳转一个新的页面网站,认为这是一种恶意广告行为,但实质所有浏览器都是支持window.open的。在百度搜索好久,有些说可以通过新建a标签,模拟点击事件触发来实现,但是测试发现都实现不了,照样被浏览器拦截(在此严重批评‘优快云博客’这个垃圾平台,没有几篇有营养的文章,互相复制粘贴也就算了,还...

weixin_36487530的博客 472

ajax请求里面调用window.open会被浏览器拦截(优化版)

众所周知,ajax请求里面调用window.open会被浏览器拦截方法有两种解决办法,但是经测验例如ajax改为async:false同步请求还会出现一些问题(比如站点外网址被拦截);第一种解决办法优化:该方法优点描述:比如ajax回调函数失败,浏览器默认打开的空链接会自动关闭,用户体验比较好。var newwin; $("#btn").click(function(){ ...

qq_29704919的博客 1356
上一篇: mysql 学习
下一篇: ilanyu
sunshinefcc
博客等级 码龄10年 17粉丝 38原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值