补上一篇的内容
上一篇让客户端JAVASCRIPT在处理事件时也能串接事件处理函数 我了极其丑陋的方法来串接事件处理句柄模拟C#中事件委托的模型,但是,方法实在是很笨,不过,经tsoukw点醒,我查了一下attachEvent方法,果然开了窍
至于有朋友问有何用途,为何不直接依次执行.我想说的是,事件处理跟直接执行是不一样的,我是想触发事件,然后依次执行几个客户端JS函数,并不是想直接执行,可能是我绑到的事件onload是一打开页面就执行,从而给了大家错误的意向吧,实际上,我的讨论是绑定到任何事件.
举个例子说,客户端JS类a绑定了一方法在window.unload事件上,客户端JS类b又绑定一方法到window.unload上,如果你用window.unload=handler的方法呢,那么,只有一个事件处理函数被引发并执行,而我想要达到的是像C#那样,依次执行绑定到的每个事件处理句柄
查了一下DHTML手册,果然查到,下面是原文

attachEvent Method


Binds the specified function to an event that fires on the object when the function is called.

Syntax

bSuccess = object.attachEvent(sEvent, fpNotify)

Parameters

sEvent Required. String that specifies any of the standard DHTML events.
fpNotify Required. Pointer that specifies the function to be called when sEvent fires.

Return Value

Boolean. Returns true if the function is bound successfully to the event, or false otherwise.

Remarks

When sEvent fires on the object, the object's sEvent handler is called before fpNotify, the specified function. If you attach multiple functions to the same event on the same object, the functions are called in random order, immediately after the object's event handler is called.

The attachEvent method enables a behavior to handle events that occur on the containing page. This method is not limited, however, to behaviors. You can also define a function on a page that attaches to events fired on the same page.

Behaviors that attach to events using the attachEvent method must explicitly call the detachEvent method to stop receiving notifications from the page when the ondetach event fires. A behavior that attaches to events on the page using the HTML Components (HTC) ATTACH element automatically stops receiving notifications when the behavior detaches from the element, and does not need to call the detachEvent method.

object.attachEvent方法可以为特定的对象的特定事件附加事件处理函数,不过上面也说了
通过此方法attach的事件处理函数会比用object.onEvent=handler指定的handler要晚执行
另外,还说明了一件事,如果你使用attachEvent方法attach多个函数的话,它们会都被执行,但是会"in randomize order"就是说,会按随机顺序执行,下面是我的测试代码
function a()
    
{
    alert(
"a");
    }

    
function b()
    
{
    alert(
"b");
    }

    
function c()
    
{
    alert(
"c");
    }

    
    window.onload
=c;
    window.attachEvent(
"onload",a);
    window.attachEvent(
"onload",b);

经测试,Ie 6.0和Opera 8.0都可以正确的执行每个处事函数,但是FireFox只能执行使用onload指定的句柄,也就是说,firefox不支持attachevent,不过,它也不会报错哟.
还有一点,在ie 中,后attach的句柄先被执行,而在Opera中,先attach的句柄先执行