惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 牦牛

Linux常用命令 错误:80040154 没有注册类 的问题 [转]Java实现定时任务的三种方法 访问IIS网站需要输入用户名密码(非匿名登录)问题汇总 IE10、IE11 User-Agent 导致的 ASP.Net 网站无法写入Cookie 问题 端口占用问题 中国电信翼支付网关接口接入 修改Tomcat响应请求时返回的Server内容 Eclipse常用设置 Tomcat服务无法启动的问题 JavaScript继承的模拟实现 Windows Server 2008 小操作汇总 手机也能连VPN,再来个远程控制PC这种事你以为我会随便说么! - 牦牛 Windows下Git服务器搭建及使用过程中的一些问题 Oracle PL/SQL中的循环处理(sql for循环) CSS的display小记 博客园添加访问人数统计 IIS故障问题(Connections_Refused)分析及处理 Windows Server 2008自定义桌面
模拟用户点击弹出新页面
牦牛 · 2014-04-08 · via 博客园 - 牦牛

模拟用户点击弹出新页面

  相信用过window.open的小伙伴们都遇到过被浏览器拦截导致页面无法弹出的情况;我们换下思路,什么情况下的新页面弹出才不会被浏览器拦截呢?比如<a />标签这种就不会;那么我们只要模拟下用户去主动点击这个<a />标签就不会有拦截的问题了。

先定义好HTML标签:

<a href="" id="alink" target="_blank" style="display: none"><span id="spanlink">test</span></a>
<input type="button" value="点我弹出新页面" onclick="targetClick()" />


然后在JS中给<a />标签赋值并触发点击事件:

1       function targetClick() {
2             $("#alink").attr("href", "http://www.163.com");
3             $("#spanlink").click();
4             return false;
5         }

OK,这下页面的弹出就畅通无阻了。

posted on 2014-04-08 12:27  牦牛  阅读(1969)  评论(3)    收藏  举报