fix-i 5.js拡張はIE 5では使用できないいくつかの方法です。
2474 ワード
IE 5のJavascript:Arayはpush()、pop()をサポートしていません。Functionはapply()をサポートしていません。Stringオブジェクトのreplace方法は1つの処理関数に置き換えることをサポートしていません。下記のコードを使用すると、上記の方法はIE 5で無効な問題を修復できます。 fix-i 5.js、 version 1.0 (pre-release) (2005/05/15) x 3 Copyright 2005 ディアン Edwards Web: http://dean.edwards.name/ This ソフトウェア is licensed アンダー?デ the CC-GNU LGPL Web: http://creativecommons.org/licenses/LGPL/2.1/ */if (/MSIE 5.0/.test(navigator.userAgent) new function() { var $$appy = function($function) $object $アーグメンント) { $function.apply($object) $アーグメンント }; // fix String.replace if (''.replace(/^/、 String) { // preserve String.replace var _ストリングレイ = String.prototype.replace; // create String.replace for handling functions var _functionReplace = function($expression) $replace ment) { var $match、 $newString = "", $ストリングス = this while ($ストリングス && ($match = $expression.exec($string))) { $newString += $string.slice(0, $match.index) + $$apply($replace ment) this、 $マッチ $ストリングス = $string.slice($match.lastIndex); } return $newString + $ストリングス }; // replace String.replace String.prototype.replace = 機能 ($expression $replace ment) { this.replace = (typeof $replace ment == "function") ? _functionReplace : _ストリングレイ return this.replace($expression) $replace ment); }; } // fix Function.apply if (!Function.apply) { var APPLY = "apply-「 + Number(new Date); $$appy = function(f o, a) { var r; o[APPLY] = f; スイッチ (a.length) { // deconstruct for スピード case 0: r = o[APPLY](); break; case 1: r = o[APPLY](a[0]) break; case 2: r = o[APPLY](a[0]、 a[1]) break; case 3: r = o[APPLY](a[0]、 a[1] a[2]) break; case 4: r = o[APPLY](a[0]、 a[1] a[2] a[3]) break; default: var a。 = [], i = a.length - 1; ド a[i] = "a[] + i + "]"; while (i--) eval(「r=o[APPLY](」 + a。 + ")"); } delete o[APPLY] return r; }; // fix ICommon ICommon.valueOf.prototype.inheit = function() { return $$apply(argments.calee.caler.ancestor) this、 アーグメンント }; } // array fixes if (![].push Aray.prototype.push = function() { for (var i = 0; i < argments.length i++) { this[this.length] = argments[i]; } return this.length }; if (![].ポップ) Aray.prototype.pop = function() { var $アイテム = this[this.length] - 1) this.length-- return $アイテム }; };