论坛首页 AJAX版 UI

IE5 和 IE6 的差别

浏览 6283 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2004-11-14
不用卖关子了,我来解开这个谜底好了。其实 IE5 和 IE6 做 JS 开发的差别几乎是没有的。最大的差别就是:
IE6(严格地说是 IE5.5/IE6)中 JS 的 Array 对象增加了两个 push 和 pop 方法,而 IE5 中 JS 的 Array 对象没有这两个方法。所以如果使用了这两个方法,在 IE5 中就肯定不能运行了。
那么这个问题是世界末日吗?需要完全放弃 IE5 吗?非也,其实只需要写两个自己的 push 和 pop 方法就可以了。例如:
Array.push = function(arr,value) {
    arr[arr.length] = value;
}
Array.pop = function(arr) {
    if (arr.length > 0) {
        var v = arr[arr.length - 1];
        arr.length--;
    }
    return v;
}

为什么这里一定要把方法定义为类方法而不是对象方法呢?如果定义为对象方法,会影响对于数组遍历的 for 循环的正确执行,所以必须要定义为类方法。这样调用起来就是这个样子了:
Array.push(arr, value);
Array.pop(arr);
用起来确实不如直接写 arr.push(value) 方便,但是这是世界末日吗?

其它的差别都是非常小的,而且很少有机会会遇到,大家来跟贴好了。
   
时间:2004-11-15
但IE5(不是IE5.5)和IE6的DOM支持有些区别。这倒是,值得关心。
   
0 请登录后投票
时间:2004-11-17
IE5 中 没有实现 call()
   
0 请登录后投票
时间:2004-11-17
这个问题有看头

可是有的浏览器的版本是6.0的也不支持push的
   
0 请登录后投票
时间:2004-11-18
jscript或javascript的版本和标准不统一;使得我对他们总是心有余悸,不敢过度依靠他们:(
   
0 请登录后投票
时间:2004-11-18
Microsoft Windows 2000 实现的 Microsoft JScript 5.1版本。有下列JScript 语言功能是5.5版本首次引入时的:
[list]0...n 属性,apply 方法,call 方法,callee 属性,charCodeAt 方法,decodeURI 方法,decodeURIComponent 方法,encodeURI 方法,encodeURIComponent 方法,global 属性,hasOwnProperty 方法,ignoreCase 属性,isPrototypeOf 方法,lastMatch 属性 ($&),lastParen 属性 ($+),leftContext 属性 ($`),length 属性(参数),localeCompare 方法,message 属性,multiline 属性,name 属性,pop 方法,propertyIsEnumerable 属性,push 方法,rightContext 属性 ($'),shift 方法,splice 方法,toDateString 方法,toExponential 方法,toFixed 方法,toLocaleDateString 方法,toLocaleLowerCase 方法,toLocaleTimeString 方法,toLocaleUpperCase 方法,toPrecision 方法,toTimeString 方法,undefined 属性,unshift 方法[/list:u]
这些里面对我来说都是可有可无的,不会影响到我平时的开发。
前天去客户那安装倒发现正式表达式里面有些是JScript5.5收入的。比如:
[list]$$ $ (JScript 5.5 or later)
$& Specifies that portion of stringObj that the entire pattern matched. (JScript 5.5 or later)
$` Specifies that portion of stringObj that precedes the match described by $&. (JScript 5.5 or later)
$' Specifies that portion of stringObj that follows the match described by $&. (JScript 5.5 or later)
$n The nth captured submatch, where n is a single decimal digit from 1 through 9. (JScript 5.5 or later)
$nn The nnth captured submatch, where nn is a two-digit decimal number from 01 through 99. (JScript 5.5 or later)
[/list:u]

像这样的代码只能是5.5才能用
[code:1]The following example, which works in JScript 5.5 and later, performs a Fahrenheit to Celsius conversion, illustrates using a function as replaceText. To see how this function works, pass in a string containing a number followed immediately by an "F" (e.g., "Water boils at 212”).

function f2c(s) {
var test = /(\d+(\.\d*)?)F\b/g; //Initialize pattern.
return(s.replace
(test,
function($0,$1,$2) {
return((($1-32) * 5/9) + "C");
}
)
);
}
document.write(f2c("Water freezes at 32F and boils at 212F."));
[/code:1]
这个让我不是很爽,正则表达式还是很好用的!
   
0 请登录后投票
时间:2004-11-18
还有像<div contentEditable>这样的标签,好像ie5是不支持的吧?我看微软的资料上说ie5.5以下是不同的。这个可以用来做在线编辑html的编辑器。
   
0 请登录后投票
时间:2004-11-23
pls IE5 不支持xslt的直接显示
   
0 请登录后投票
时间:2004-11-25
对CSS的解释不同,开发CSS时要分别对待
   
0 请登录后投票
时间:2004-12-05
冷汗……原来IE5不支持Array的push和pop方法啊?我一直以为这是很JavaScript中很基础的两个方法呢。
唉,不过现在的这不争气的JavaScript真是越来越不被重视了,最近面试,很多说JavaScript还不错的我问:JavaScript同JScript有什么区别,主流浏览器支持到哪个版本?基本没人知道。
   
0 请登录后投票
论坛首页 AJAX版 UI

跳转论坛:
JavaEye推荐