IIssNan's Notes

Quick notes


  • 首页

  • 归档

  • 标签

  • 搜索

根据浏览器特性判断 IE7 浏览器

发表于 2011-12-23 | | 阅读次数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function isIE() {
return document.all ? true : false;
}
function isIE6() {
return typeof document.body.style.maxHeight === 'undefined';
}
function isIE7(){
if ( !isIE() || isIE6() ) {
return false;
} else {
var xDocumentMode = document.documentMode;
var isVersion7 = navigator.appVersion.indexOf('MSIE 7.') > -1;
if (isVersion7) {
// 检测是否支持 documentMode
// 或 documentMode === 7
// IE8兼容性视图 / IE9 下 X-UA-Compatible 为 EmulateIE7,IE7
return xDocumentMode === 7 || !xDocumentMode;
}
return false;
}
}

Understanding Compatibility Modes in Internet Explorer 8

发表于 2011-12-23 | | 阅读次数

CSS Expression

发表于 2011-12-22 | | 阅读次数

CSS Expression简述

CSS Expression 是微软的专有技术,只有 Windows 下的 IE 浏览器支持,其他浏览器均对 expression 表达式不识别。

受影响的浏览器

IE6 IE7 IE8(Q)。IE8 标准模式已不再支持 CSS Expression

常用场景

  • max-width, max-height等
  • position:fixed

Detecting IE6 using features

发表于 2011-12-20 | | 阅读次数

通过判断 body.style.maxHeight(IE7开始支持 max-width, max-height):

1
2
3
4
5
if (typeof document.body.style.maxHeight !== 'undefined') {
// IE7+, Mozilla, safari, Opera
} else {
// IE6-
}

或者判断 window.XMLHttpRequest 对象:

1
2
3
4
5
if (window.XMLHttpRequest) {
// IE7+, Mozilla, safari, Opera
} else {
// IE6-
}

除此两个使用特性做检测的方法外,还有条件注释等方法。应用场景比如:置顶工具条或者其他固定位置的元素(position:fixed)

参考资料:

  • Detecting IE7+ in JavaScript - Ajaxian

Best practice: escape, or encodeURI / encodeURIComponent

发表于 2011-12-12 | | 阅读次数

关于 JavaScript 中的 escape、encodeURI、encodeURIComponent 三个函数,答案一针见血。另外,底下的其他回复也很有参考价值。

1…293031…37
IIssNan

IIssNan

胡编一通,乱写一气

183 日志
6 分类
111 标签
RSS
GitHub Twitter 豆瓣 知乎
© 2011 - 2017 IIssNan
由 Hexo 强力驱动
主题 - NexT.Pisces
0%