Archives

Archive for 2009-4

获得Javascript 对象的属性个数

//扩展对象的count方法

Object.prototype.count = (

    Object.prototype.hasOwnProperty(‘__count__’)

  ) ? function () {

    return this.__count__;

  } : function () {

    var count = 0;

    for (var i in this) if (this.hasOwnProperty(i)) {

      count ++;

    }

    return count;

  };

 

//使用

var myObj = {

    name1: “value1″,

    name2: “value2″

};

 

alert(myObj.count());

<script language=”javascript” type=”text/javascript” charset=”utf-8″>

Just a reminder, the <script> tag, in all browsers that support it, defaults to being interpreted as the javascript language, of mime-type text/javascript, and of charset UTF-8. You don’t need to specify any of these values.
In fact, you can’t reliably change the charset, even with the charset attribute, so it’s generally best not to […]

Flash debug player 导致的磁盘空间不足

( Flash )

总出现C盘空间不足的系统提示,百思不得其解,在对C盘文件夹排查后发现,C:\Documents and Settings\×××\Application Data\Macromedia\Flash Player\Logs 里面有一个flashlog.txt 文件达2G多,突然想到这是flash debug player产生的debug信息。
由于不少网站做的FLASH会有很多trace语句没有清楚干净,或者存在bug或者运行时错误,这样在flash debug player版本就会不断的生成debug信息,致使flashlog.txt 文件越来越大。
重启系统删除此文件后,磁盘立刻空闲出2G多的空间。
所以,在flash日常开发中,发布版本的程序要进行debug信息的去除,和在debug player下进行验证,防止出现类似问题。
目前许多使用flash的视频网站均存在类似问题,比如优库网。