国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > JS > 正文

fix-ie5.js擴(kuò)展在IE5下不能使用的幾個方法

2024-09-06 12:41:42
字體:
供稿:網(wǎng)友
在IE5下的Javascript:
Array不支持push(),pop();Function不支持apply();String對象的replace方法不支持替換成一個處理函數(shù)。
使用下面的代碼就可修復(fù)上述方法在IE5下無效的問題。
/*
  fix-ie5.js, version 1.0 (pre-release) (2005/05/15) x3
  Copyright 2005, Dean Edwards
  Web: http://dean.edwards.name/

  This software is licensed under the CC-GNU LGPL
  Web: http://creativecommons.org/licenses/LGPL/2.1/
*/

if (/MSIE 5.0/.test(navigator.userAgent)) new function() {

  var $$apply = function($function, $object, $arguments) {
    $function.apply($object, $arguments);
  };

  // fix String.replace
  if (''.replace(/^/, String)) {
    // preserve String.replace
    var _stringReplace = String.prototype.replace;
    // create String.replace for handling functions
    var _functionReplace = function($expression, $replacement) {
      var $match, $newString = "", $string = this;
      while ($string && ($match = $expression.exec($string))) {
        $newString += $string.slice(0, $match.index) + $$apply($replacement, this, $match);
        $string = $string.slice($match.lastIndex);
      }
      return $newString + $string;
    };
    // replace String.replace
    String.prototype.replace = function ($expression, $replacement) {
      this.replace = (typeof $replacement == "function") ? _functionReplace : _stringReplace;
      return this.replace($expression, $replacement);
    };
  }

  // fix Function.apply
  if (!Function.apply) {
    var APPLY = "apply-" + Number(new Date);
    $$apply = function(f, o, a) {
      var r;
      o[APPLY] = f;
      switch (a.length) { // deconstruct for speed
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 桐庐县| 洞口县| 旺苍县| 噶尔县| 木兰县| 陆河县| 灌云县| 宜川县| 南平市| 峨眉山市| 博白县| 安宁市| 阳高县| 浑源县| 精河县| 翁源县| 平昌县| 鲁甸县| 满洲里市| 竹北市| 天门市| 斗六市| 乌兰浩特市| 崇州市| 太和县| 洛扎县| 大足县| 读书| 平遥县| 德令哈市| 巴彦淖尔市| 方正县| 嵊州市| 长岛县| 岳阳市| 三穗县| 调兵山市| 长沙县| 始兴县| 林芝县| 扎兰屯市|