<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_Tutorial%2FEvent%2FzEvents</id>
		<title>JavaScript Tutorial/Event/zEvents - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_Tutorial%2FEvent%2FzEvents"/>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_Tutorial/Event/zEvents&amp;action=history"/>
		<updated>2026-04-05T18:11:35Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_Tutorial/Event/zEvents&amp;diff=8767&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_Tutorial/Event/zEvents&amp;diff=8767&amp;oldid=prev"/>
				<updated>2010-05-26T08:24:33Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 08:24, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_Tutorial/Event/zEvents&amp;diff=8766&amp;oldid=prev</id>
		<title> в 18:52, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_Tutorial/Event/zEvents&amp;diff=8766&amp;oldid=prev"/>
				<updated>2010-05-25T18:52:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== The preventDefault() method from zEvent is used to prevent the running flag from being set to true==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.0 Transitional//EN&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;Page title&amp;lt;/title&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
/*------------------------------------------------------------------------------&lt;br /&gt;
 * JavaScript zEvents Library&lt;br /&gt;
 * Version 1.1&lt;br /&gt;
 * by Nicholas C. Zakas, http://www.nczonline.net/&lt;br /&gt;
 * Copyright (c) 2004-2005 Nicholas C. Zakas. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
 * GNU Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this program; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA&lt;br /&gt;
 *------------------------------------------------------------------------------&lt;br /&gt;
 */  &lt;br /&gt;
/**&lt;br /&gt;
 * Encapsulates information about an event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @class&lt;br /&gt;
 */&lt;br /&gt;
function zEvent() {&lt;br /&gt;
    /**&lt;br /&gt;
     * The type of event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.type /*: String */   = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The object that caused the event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.target /*: zEventTarget */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * A secondary object related to the event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.relatedTarget /*: zEventTarget */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Indicates whether or not the event can be canceled.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.cancelable /*: boolean */ = false;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The time that the event occurred.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.timeStamp /*: long */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /*&lt;br /&gt;
     * Set to false to cancel event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.returnValue /*: boolean */ = true;    &lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Initializes the event object with information for the event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event encapsulated by the object.&lt;br /&gt;
 * @param bCancelable True if the event can be cancelled.&lt;br /&gt;
 */&lt;br /&gt;
zEvent.prototype.initEvent = function (sType /*: String */,&lt;br /&gt;
                                       bCancelable /*: boolean */) {&lt;br /&gt;
    this.type = sType;&lt;br /&gt;
    this.cancelable = bCancelable;&lt;br /&gt;
    this.timeStamp = (new Date()).getTime();&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Prevents the default behavior for an event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 */&lt;br /&gt;
zEvent.prototype.preventDefault = function () {&lt;br /&gt;
    if (this.cancelable) {&lt;br /&gt;
        this.returnValue = false;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Any class that wants to support events should inherit from this.&lt;br /&gt;
 * @class&lt;br /&gt;
 * @scope public&lt;br /&gt;
 */&lt;br /&gt;
function zEventTarget() {&lt;br /&gt;
    /**&lt;br /&gt;
     * Array of event handlers.&lt;br /&gt;
     * @scope private&lt;br /&gt;
     */&lt;br /&gt;
    this.eventhandlers /*: Object */ = new Object();&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Adds an event listener function to handle the type of event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event to handle (i.e., &amp;quot;mousemove&amp;quot;, not &amp;quot;onmousemove&amp;quot;).&lt;br /&gt;
 * @param fnListener The listener function for the event.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.addEventListener = function (sType /*: String */,&lt;br /&gt;
                                                    fnListener /*: Function */) {&lt;br /&gt;
    if (typeof this.eventhandlers[sType] == &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        this.eventhandlers[sType] = new Array;&lt;br /&gt;
    }   &lt;br /&gt;
    &lt;br /&gt;
    this.eventhandlers[sType][this.eventhandlers[sType].length] = fnListener;                                                    &lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Causes an event to fire.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param oEvent The event object containing information about the event to fire.&lt;br /&gt;
 * @return True if the event should continue, false if not.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.dispatchEvent = function (oEvent /*: zEvent */) /*: boolean */ {&lt;br /&gt;
    /*&lt;br /&gt;
     * Set the target of the event.&lt;br /&gt;
     */&lt;br /&gt;
    oEvent.target = this;&lt;br /&gt;
    /*&lt;br /&gt;
     * Call each event handler and pass in the event object.&lt;br /&gt;
     */&lt;br /&gt;
    if (typeof this.eventhandlers[oEvent.type] != &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        for (var i=0; i &amp;lt; this.eventhandlers[oEvent.type].length; i++) {    &lt;br /&gt;
            this.eventhandlers[oEvent.type][i](oEvent);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * Return the value of returnValue, which is changed to false&lt;br /&gt;
     * when preventDefault() is called.&lt;br /&gt;
     */&lt;br /&gt;
    return oEvent.returnValue;                                                   &lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Removes an event listener function from handling the type of event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event to remove from (i.e., &amp;quot;mousemove&amp;quot;, not &amp;quot;onmousemove&amp;quot;).&lt;br /&gt;
 * @param fnListener The listener function to remove.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.removeEventListener = function (sType /*: String */,&lt;br /&gt;
                                                       fnListener /*: Function */) {&lt;br /&gt;
    if (typeof this.eventhandlers[sType] != &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        var arrTemp = new Array;&lt;br /&gt;
        for (var i=0; i &amp;lt; this.eventhandlers[sType].length; i++) {&lt;br /&gt;
            if (this.eventhandlers[sType][i] != fnListener) {&lt;br /&gt;
                arrTemp[arrTemp.length] = this.eventhandlers[sType][i];&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        this.eventhandlers[sType] = arrTemp;&lt;br /&gt;
    }   &lt;br /&gt;
                                                   &lt;br /&gt;
};&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
//sample class&lt;br /&gt;
function Car() {&lt;br /&gt;
    //inherit properties from zEventTarget&lt;br /&gt;
    zEventTarget.apply(this);&lt;br /&gt;
    //property indicating if the car is running&lt;br /&gt;
    this.running = false;&lt;br /&gt;
}&lt;br /&gt;
//inherit methods from zEventTarget&lt;br /&gt;
Car.prototype = new zEventTarget();&lt;br /&gt;
//method to start engine&lt;br /&gt;
Car.prototype.start = function () {&lt;br /&gt;
    //create event object&lt;br /&gt;
    var oEvent = new zEvent();&lt;br /&gt;
    //the event is called &amp;quot;start&amp;quot; and is cancelable&lt;br /&gt;
    oEvent.initEvent(&amp;quot;start&amp;quot;, true);&lt;br /&gt;
    //fire the event&lt;br /&gt;
    if (this.dispatchEvent(oEvent)) {&lt;br /&gt;
       //if dispatchEvent() returns true, set the flag&lt;br /&gt;
       this.running = true;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
//method to stop engine&lt;br /&gt;
Car.prototype.stop = function () {&lt;br /&gt;
    //create event object&lt;br /&gt;
    var oEvent = new zEvent();&lt;br /&gt;
    //the event is called &amp;quot;stop&amp;quot; and is cancelable&lt;br /&gt;
    oEvent.initEvent(&amp;quot;stop&amp;quot;, true);&lt;br /&gt;
    //fire the event&lt;br /&gt;
    if (this.dispatchEvent(oEvent)) {&lt;br /&gt;
        //if dispatchEvent() returns true, set the flag&lt;br /&gt;
        this.running = false;&lt;br /&gt;
    }&lt;br /&gt;
};             &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
           //sample object&lt;br /&gt;
           var oCar = new Car();&lt;br /&gt;
           &lt;br /&gt;
           //assign event handler for &amp;quot;start&amp;quot; event&lt;br /&gt;
           oCar.addEventListener(&amp;quot;start&amp;quot;, function(oEvent) {&lt;br /&gt;
               alert(&amp;quot;Cancelling the start...&amp;quot;);&lt;br /&gt;
               oEvent.preventDefault();&lt;br /&gt;
           });&lt;br /&gt;
           &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
            //call the start() method&lt;br /&gt;
            oCar.start();&lt;br /&gt;
            &lt;br /&gt;
            //now, what is the value of running?&lt;br /&gt;
            alert(&amp;quot;Running: &amp;quot; + oCar.running);&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;P&amp;gt;This example uses more complex event handlers and the &amp;lt;code&amp;gt;zEvent&amp;lt;/code&amp;gt;&lt;br /&gt;
        object. Also, the &amp;lt;code&amp;gt;preventDefault()&amp;lt;/code&amp;gt; method is used to prevent the &amp;lt;code&amp;gt;running&amp;lt;/code&amp;gt;&lt;br /&gt;
        flag from being set to true.&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
== This example uses more complex event handlers and the zEvent object==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.0 Transitional//EN&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;Page title&amp;lt;/title&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
/*------------------------------------------------------------------------------&lt;br /&gt;
 * JavaScript zEvents Library&lt;br /&gt;
 * Version 1.1&lt;br /&gt;
 * by Nicholas C. Zakas, http://www.nczonline.net/&lt;br /&gt;
 * Copyright (c) 2004-2005 Nicholas C. Zakas. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
 * GNU Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this program; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA&lt;br /&gt;
 *------------------------------------------------------------------------------&lt;br /&gt;
 */  &lt;br /&gt;
/**&lt;br /&gt;
 * Encapsulates information about an event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @class&lt;br /&gt;
 */&lt;br /&gt;
function zEvent() {&lt;br /&gt;
    /**&lt;br /&gt;
     * The type of event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.type /*: String */   = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The object that caused the event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.target /*: zEventTarget */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * A secondary object related to the event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.relatedTarget /*: zEventTarget */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Indicates whether or not the event can be canceled.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.cancelable /*: boolean */ = false;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The time that the event occurred.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.timeStamp /*: long */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /*&lt;br /&gt;
     * Set to false to cancel event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.returnValue /*: boolean */ = true;    &lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Initializes the event object with information for the event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event encapsulated by the object.&lt;br /&gt;
 * @param bCancelable True if the event can be cancelled.&lt;br /&gt;
 */&lt;br /&gt;
zEvent.prototype.initEvent = function (sType /*: String */,&lt;br /&gt;
                                       bCancelable /*: boolean */) {&lt;br /&gt;
    this.type = sType;&lt;br /&gt;
    this.cancelable = bCancelable;&lt;br /&gt;
    this.timeStamp = (new Date()).getTime();&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Prevents the default behavior for an event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 */&lt;br /&gt;
zEvent.prototype.preventDefault = function () {&lt;br /&gt;
    if (this.cancelable) {&lt;br /&gt;
        this.returnValue = false;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Any class that wants to support events should inherit from this.&lt;br /&gt;
 * @class&lt;br /&gt;
 * @scope public&lt;br /&gt;
 */&lt;br /&gt;
function zEventTarget() {&lt;br /&gt;
    /**&lt;br /&gt;
     * Array of event handlers.&lt;br /&gt;
     * @scope private&lt;br /&gt;
     */&lt;br /&gt;
    this.eventhandlers /*: Object */ = new Object();&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Adds an event listener function to handle the type of event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event to handle (i.e., &amp;quot;mousemove&amp;quot;, not &amp;quot;onmousemove&amp;quot;).&lt;br /&gt;
 * @param fnListener The listener function for the event.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.addEventListener = function (sType /*: String */,&lt;br /&gt;
                                                    fnListener /*: Function */) {&lt;br /&gt;
    if (typeof this.eventhandlers[sType] == &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        this.eventhandlers[sType] = new Array;&lt;br /&gt;
    }   &lt;br /&gt;
    &lt;br /&gt;
    this.eventhandlers[sType][this.eventhandlers[sType].length] = fnListener;                                                    &lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Causes an event to fire.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param oEvent The event object containing information about the event to fire.&lt;br /&gt;
 * @return True if the event should continue, false if not.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.dispatchEvent = function (oEvent /*: zEvent */) /*: boolean */ {&lt;br /&gt;
    /*&lt;br /&gt;
     * Set the target of the event.&lt;br /&gt;
     */&lt;br /&gt;
    oEvent.target = this;&lt;br /&gt;
    /*&lt;br /&gt;
     * Call each event handler and pass in the event object.&lt;br /&gt;
     */&lt;br /&gt;
    if (typeof this.eventhandlers[oEvent.type] != &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        for (var i=0; i &amp;lt; this.eventhandlers[oEvent.type].length; i++) {    &lt;br /&gt;
            this.eventhandlers[oEvent.type][i](oEvent);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * Return the value of returnValue, which is changed to false&lt;br /&gt;
     * when preventDefault() is called.&lt;br /&gt;
     */&lt;br /&gt;
    return oEvent.returnValue;                                                   &lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Removes an event listener function from handling the type of event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event to remove from (i.e., &amp;quot;mousemove&amp;quot;, not &amp;quot;onmousemove&amp;quot;).&lt;br /&gt;
 * @param fnListener The listener function to remove.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.removeEventListener = function (sType /*: String */,&lt;br /&gt;
                                                       fnListener /*: Function */) {&lt;br /&gt;
    if (typeof this.eventhandlers[sType] != &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        var arrTemp = new Array;&lt;br /&gt;
        for (var i=0; i &amp;lt; this.eventhandlers[sType].length; i++) {&lt;br /&gt;
            if (this.eventhandlers[sType][i] != fnListener) {&lt;br /&gt;
                arrTemp[arrTemp.length] = this.eventhandlers[sType][i];&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        this.eventhandlers[sType] = arrTemp;&lt;br /&gt;
    }   &lt;br /&gt;
                                                   &lt;br /&gt;
};&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
//sample class&lt;br /&gt;
function Car() {&lt;br /&gt;
    //inherit properties from zEventTarget&lt;br /&gt;
    zEventTarget.apply(this);&lt;br /&gt;
    //property indicating if the car is running&lt;br /&gt;
    this.running = false;&lt;br /&gt;
}&lt;br /&gt;
//inherit methods from zEventTarget&lt;br /&gt;
Car.prototype = new zEventTarget();&lt;br /&gt;
//method to start engine&lt;br /&gt;
Car.prototype.start = function () {&lt;br /&gt;
    //create event object&lt;br /&gt;
    var oEvent = new zEvent();&lt;br /&gt;
    //the event is called &amp;quot;start&amp;quot; and is cancelable&lt;br /&gt;
    oEvent.initEvent(&amp;quot;start&amp;quot;, true);&lt;br /&gt;
    //fire the event&lt;br /&gt;
    if (this.dispatchEvent(oEvent)) {&lt;br /&gt;
       //if dispatchEvent() returns true, set the flag&lt;br /&gt;
       this.running = true;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
//method to stop engine&lt;br /&gt;
Car.prototype.stop = function () {&lt;br /&gt;
    //create event object&lt;br /&gt;
    var oEvent = new zEvent();&lt;br /&gt;
    //the event is called &amp;quot;stop&amp;quot; and is cancelable&lt;br /&gt;
    oEvent.initEvent(&amp;quot;stop&amp;quot;, true);&lt;br /&gt;
    //fire the event&lt;br /&gt;
    if (this.dispatchEvent(oEvent)) {&lt;br /&gt;
        //if dispatchEvent() returns true, set the flag&lt;br /&gt;
        this.running = false;&lt;br /&gt;
    }&lt;br /&gt;
};             &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
           //sample object&lt;br /&gt;
           var oCar = new Car();&lt;br /&gt;
           &lt;br /&gt;
           //assign event handler for &amp;quot;start&amp;quot; event&lt;br /&gt;
           oCar.addEventListener(&amp;quot;start&amp;quot;, function(oEvent) {&lt;br /&gt;
               alert(&amp;quot;Event name: &amp;quot; + oEvent.type);&lt;br /&gt;
               alert(&amp;quot;Event can be cancelled: &amp;quot; + oEvent.cancelable);&lt;br /&gt;
           });&lt;br /&gt;
           &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
            //call the start() method&lt;br /&gt;
            oCar.start();&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;P&amp;gt;This example uses more complex event handlers and the &amp;lt;code&amp;gt;zEvent&amp;lt;/code&amp;gt;&lt;br /&gt;
        object.&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
== This example uses simple event handlers to alert you when the start() and stop() methods are called==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.0 Transitional//EN&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;Page title&amp;lt;/title&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
/*------------------------------------------------------------------------------&lt;br /&gt;
 * JavaScript zEvents Library&lt;br /&gt;
 * Version 1.1&lt;br /&gt;
 * by Nicholas C. Zakas, http://www.nczonline.net/&lt;br /&gt;
 * Copyright (c) 2004-2005 Nicholas C. Zakas. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
 * GNU Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this program; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA&lt;br /&gt;
 *------------------------------------------------------------------------------&lt;br /&gt;
 */  &lt;br /&gt;
/**&lt;br /&gt;
 * Encapsulates information about an event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @class&lt;br /&gt;
 */&lt;br /&gt;
function zEvent() {&lt;br /&gt;
    /**&lt;br /&gt;
     * The type of event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.type /*: String */   = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The object that caused the event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.target /*: zEventTarget */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * A secondary object related to the event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.relatedTarget /*: zEventTarget */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Indicates whether or not the event can be canceled.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.cancelable /*: boolean */ = false;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The time that the event occurred.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.timeStamp /*: long */ = null;&lt;br /&gt;
    &lt;br /&gt;
    /*&lt;br /&gt;
     * Set to false to cancel event.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.returnValue /*: boolean */ = true;    &lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Initializes the event object with information for the event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event encapsulated by the object.&lt;br /&gt;
 * @param bCancelable True if the event can be cancelled.&lt;br /&gt;
 */&lt;br /&gt;
zEvent.prototype.initEvent = function (sType /*: String */,&lt;br /&gt;
                                       bCancelable /*: boolean */) {&lt;br /&gt;
    this.type = sType;&lt;br /&gt;
    this.cancelable = bCancelable;&lt;br /&gt;
    this.timeStamp = (new Date()).getTime();&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Prevents the default behavior for an event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 */&lt;br /&gt;
zEvent.prototype.preventDefault = function () {&lt;br /&gt;
    if (this.cancelable) {&lt;br /&gt;
        this.returnValue = false;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Any class that wants to support events should inherit from this.&lt;br /&gt;
 * @class&lt;br /&gt;
 * @scope public&lt;br /&gt;
 */&lt;br /&gt;
function zEventTarget() {&lt;br /&gt;
    /**&lt;br /&gt;
     * Array of event handlers.&lt;br /&gt;
     * @scope private&lt;br /&gt;
     */&lt;br /&gt;
    this.eventhandlers /*: Object */ = new Object();&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Adds an event listener function to handle the type of event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event to handle (i.e., &amp;quot;mousemove&amp;quot;, not &amp;quot;onmousemove&amp;quot;).&lt;br /&gt;
 * @param fnListener The listener function for the event.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.addEventListener = function (sType /*: String */,&lt;br /&gt;
                                                    fnListener /*: Function */) {&lt;br /&gt;
    if (typeof this.eventhandlers[sType] == &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        this.eventhandlers[sType] = new Array;&lt;br /&gt;
    }   &lt;br /&gt;
    &lt;br /&gt;
    this.eventhandlers[sType][this.eventhandlers[sType].length] = fnListener;                                                    &lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Causes an event to fire.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param oEvent The event object containing information about the event to fire.&lt;br /&gt;
 * @return True if the event should continue, false if not.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.dispatchEvent = function (oEvent /*: zEvent */) /*: boolean */ {&lt;br /&gt;
    /*&lt;br /&gt;
     * Set the target of the event.&lt;br /&gt;
     */&lt;br /&gt;
    oEvent.target = this;&lt;br /&gt;
    /*&lt;br /&gt;
     * Call each event handler and pass in the event object.&lt;br /&gt;
     */&lt;br /&gt;
    if (typeof this.eventhandlers[oEvent.type] != &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        for (var i=0; i &amp;lt; this.eventhandlers[oEvent.type].length; i++) {    &lt;br /&gt;
            this.eventhandlers[oEvent.type][i](oEvent);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * Return the value of returnValue, which is changed to false&lt;br /&gt;
     * when preventDefault() is called.&lt;br /&gt;
     */&lt;br /&gt;
    return oEvent.returnValue;                                                   &lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Removes an event listener function from handling the type of event.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sType The type of event to remove from (i.e., &amp;quot;mousemove&amp;quot;, not &amp;quot;onmousemove&amp;quot;).&lt;br /&gt;
 * @param fnListener The listener function to remove.&lt;br /&gt;
 */&lt;br /&gt;
zEventTarget.prototype.removeEventListener = function (sType /*: String */,&lt;br /&gt;
                                                       fnListener /*: Function */) {&lt;br /&gt;
    if (typeof this.eventhandlers[sType] != &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        var arrTemp = new Array;&lt;br /&gt;
        for (var i=0; i &amp;lt; this.eventhandlers[sType].length; i++) {&lt;br /&gt;
            if (this.eventhandlers[sType][i] != fnListener) {&lt;br /&gt;
                arrTemp[arrTemp.length] = this.eventhandlers[sType][i];&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        this.eventhandlers[sType] = arrTemp;&lt;br /&gt;
    }   &lt;br /&gt;
                                                   &lt;br /&gt;
};&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
//sample class&lt;br /&gt;
function Car() {&lt;br /&gt;
    //inherit properties from zEventTarget&lt;br /&gt;
    zEventTarget.apply(this);&lt;br /&gt;
    //property indicating if the car is running&lt;br /&gt;
    this.running = false;&lt;br /&gt;
}&lt;br /&gt;
//inherit methods from zEventTarget&lt;br /&gt;
Car.prototype = new zEventTarget();&lt;br /&gt;
//method to start engine&lt;br /&gt;
Car.prototype.start = function () {&lt;br /&gt;
    //create event object&lt;br /&gt;
    var oEvent = new zEvent();&lt;br /&gt;
    //the event is called &amp;quot;start&amp;quot; and is cancelable&lt;br /&gt;
    oEvent.initEvent(&amp;quot;start&amp;quot;, true);&lt;br /&gt;
    //fire the event&lt;br /&gt;
    if (this.dispatchEvent(oEvent)) {&lt;br /&gt;
       //if dispatchEvent() returns true, set the flag&lt;br /&gt;
       this.running = true;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
//method to stop engine&lt;br /&gt;
Car.prototype.stop = function () {&lt;br /&gt;
    //create event object&lt;br /&gt;
    var oEvent = new zEvent();&lt;br /&gt;
    //the event is called &amp;quot;stop&amp;quot; and is cancelable&lt;br /&gt;
    oEvent.initEvent(&amp;quot;stop&amp;quot;, true);&lt;br /&gt;
    //fire the event&lt;br /&gt;
    if (this.dispatchEvent(oEvent)) {&lt;br /&gt;
        //if dispatchEvent() returns true, set the flag&lt;br /&gt;
        this.running = false;&lt;br /&gt;
    }&lt;br /&gt;
};             &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
           //sample object&lt;br /&gt;
           var oCar = new Car();&lt;br /&gt;
           &lt;br /&gt;
           //assign event handler for &amp;quot;start&amp;quot; event&lt;br /&gt;
           oCar.addEventListener(&amp;quot;start&amp;quot;, function() {&lt;br /&gt;
               alert(&amp;quot;starting&amp;quot;);&lt;br /&gt;
           });&lt;br /&gt;
           &lt;br /&gt;
           //assign event handler for &amp;quot;stop&amp;quot; event&lt;br /&gt;
           oCar.addEventListener(&amp;quot;stop&amp;quot;, function() {&lt;br /&gt;
               alert(&amp;quot;stopping&amp;quot;);&lt;br /&gt;
           });&lt;br /&gt;
           &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
            //call the start() method&lt;br /&gt;
            oCar.start();&lt;br /&gt;
            &lt;br /&gt;
            //check to make sure the car is running&lt;br /&gt;
            alert(&amp;quot;Running:&amp;quot; + oCar.running);&lt;br /&gt;
            &lt;br /&gt;
            //call the stop() method&lt;br /&gt;
            oCar.stop();&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;P&amp;gt;This example uses simple event handlers to alert you when the&lt;br /&gt;
        &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; methods are called.&amp;lt;/p&amp;gt;&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>