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

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - 深蓝--广州

AngularJs angular.identity和angular.noop详解 css中clearfix清除浮动的用法及其原理示例介绍 opacity与RGBA透明的区别 CSS3 Gradient javascript语言精粹 严格模式认识 Promise与Defer认识 关于浏览器缓存 ie6下js更新元素display:block后,仍然不显示的hack办法 jQuery jsonp无法捕获404、500状态错误 移动端开发问题整理 修改input的type属性 transform:rotate在手机上显示有锯齿的解决方案 javascript钩子机制 jQuery.validate 常用方法及注意问题 SWFObject推出2使用示例 .NET种Json时对单引号和特殊字符串的处理 自定义枚举类型注释属性,并在程序中获取 Python Win32 Extensions
使用javascript打开一个新页而不被浏览器屏蔽
深蓝--广州 · 2016-04-26 · via 博客园 - 深蓝--广州

使用javascript打开一个新页面可以有几种方式,但各有利弊,以下做下分析

1.window.open(url)

这是新手最常用的方法,好处是简单易用,坏处,很简单,会被很多浏览器拦截而导致功能失效

2.使用js在页面创建一个a标签,然后点击它

示例代码如下:

                var a = document.getElementById("entergameform1001");
                if(!a){
                    $(document.body).append('<a id="entergameform1001" href="' + url + '" target="_blank"></a>');
                    a = document.getElementById("entergameform1001");
                }else{
                    $(a).attr("href",url);
                }
                a.click();

优点,不会被浏览器拦截,但是两个窗口交互的话,会找不到window.owner

3.使用js创建一个form表单,模拟表单提交

示例代码如下:

                var form = document.getElementById("entergameform1001");
                if(!form){
                    $(document.body).append('<form id="entergameform1001" action="' + url + '" method="get" target="_blank"></form>');
                    form = document.getElementById("entergameform1001");
                }else{
                    $(form).attr("action",url);
                }
                form.submit();

优点:相关a标签,页面可以获取window.owner。缺点:使用get方式,在部分浏览器中,url里的参数会被过滤掉,必须使用input值来传递。使用post提交时,会被浏览器拦截