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

推荐订阅源

P
Palo Alto Networks Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cyberwarzone
Cyberwarzone
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
Security Latest
Security Latest
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
C
Cisco Blogs
博客园 - 【当耐特】
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
B
Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
The Last Watchdog
The Last Watchdog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
F
Fortinet All Blogs
L
LINUX DO - 热门话题
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
爱范儿
爱范儿
O
OpenAI News
J
Java Code Geeks
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - pomp

Jquery资源-床头必备 全球网络的主色调是什么? user-agent检测详解 【转】前端开发大众手册(包括工具、网址、经验等) 详解Javascript事件驱动的来龙去脉【转】 基于JQuery的7款选项卡(Tabs)实例 什么是ImageLazyLoad技术 IE6下PNG图片透明 (二) 样式定义的权重问题 记录【转】 ie6 下最佳 PNG透明方案【转】 乔布斯:关于 Flash 的思考[转] Flex 开发必备10武器(转载) Flex4 SDK 新特性 PPT SQL中获得EXEC后面的sql语句或者存储过程的返回值的方法 【收藏】 SQL存储过程学习中的概念汇总 CuteEditor编辑器(转) SqlDataSource查询设置 sql select语句详解 跨页传值方法集锦
Javascript 判断浏览器是否为IE的最短方法
pomp · 2010-05-03 · via 博客园 - pomp

Javascript 判断浏览器是否为IE的最短方法

作者:idd.chiang 发布时间:April 29, 2010 分类:Javascript/AS

在网上有幸看到夷人通过IE与非IE浏览器对垂直制表符支持特性搞出的一段简短的条件:

var ie = !+"\v1";

以上出至32 bytes, ehr ... 9, ehr ... 7!!! to know if your browser is IE(需FQ)

而 更有牛人,据说是俄国大力士用6byte的长度将上面已经看似不能再短的判定条件记录刷新,如下:

//IE下为true
var ie = !-[1,];

利用了IE与标准浏览器在处理数组的toString方法的差异做成的。对于标准游览器,如果数组里面最后一个字符为逗号,JS 引擎会自动剔除它。

自己试验了一下,效果还不错,推荐给大家看看

if(!-[1,]){
    alert('是IE!')
}else{
    alert('非IE!')
}

该方法是否值得推广必须经得各位的多番验证,现在还不能说是最有效的方法,不过这种取巧能在很多需要敏捷开发时用到。