SafariEvent Class Reference

Technology area
Safari Extensions
Availability
Available in Safari 5.0 and later.

Overview

The SafariEvent class is a base class used to encapsulate events. Developers who are familiar with DOM events will notice many similarities in design and behavior.

Events are sent to their target and its ancestors in three phases. In order, they are as follows:

  1. Capturing. The event is sent to every ancestor of the its target, starting with the most distant ancestor, and ending with the parent of the event’s target.

  2. Targeting. The event is sent to its target.

  3. Bubbling. The event is sent to every ancestor of its target, starting with the parent of the event’s target, and ending with its most distant ancestor.

You can tell which phase an event is in from the value of its eventPhase property. When you register for an event notification, you specify whether or not you want to be notified during the capturing phase. Therefore, you may not always need to check what phase the event is in.

Tasks

Targeting Events

Interacting with Event Propagation

Preventing the Default Action

Properties

bubbles

A Boolean value that indicates whether the event goes through the bubbling phase.

readonly attribute boolean bubbles
Availability

cancelable

A Boolean value that indicates whether the event can be canceled.

readonly attribute boolean cancelable
Availability
See Also

currentTarget

The object that the event is currently being sent to.

readonly attribute SafariEventTarget currentTarget
Discussion

This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy.

Availability

defaultPrevented

A Boolean value that indicates whether the event’s default action has been prevented.

readonly attribute boolean defaultPrevented
Availability

eventPhase

The event-handling phase that the event is in.

readonly attribute unsigned short eventPhase
Discussion

The values for this property are the same as the values used by Webkit to identify the event-handling phases. See “Event Handling Phases.”

Availability

target

The target of the event.

readonly attribute SafariEventTarget target
Discussion

This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase.

Availability

timeStamp

The time and date that the event was created.

readonly attribute DOMTimeStamp timeStamp
Availability

type

The type of the event.

readonly attribute DOMString type
Discussion

The string used to identify a particular type of event is documented in the reference for that class.

Availability

Methods

preventDefault

Prevents the browser from performing the default action for an event.

void preventDefault ()
Discussion

Use this method to indicate that your extension has already fully handled the event; you don’t want the browser to do anything. Note that preventing the default action does not stop an event from propagating.

Availability
  • Available in Safari 5.0 and later.

stopPropagation

Prevents the event from any further propagation.

void stopPropagation ()
Discussion

Propagation can be stopped only fon cancelable events. After propagation is stopped, the event is not sent to any other targets.

Availability
  • Available in Safari 5.0 and later.
See Also

Constants

Event-Handling Phases

Phases of the event-handling process.

Constants
BUBBLING_PHASE

The bubbling phase.

Available in Safari 5.1 and later.

CAPTURING_PHASE

The capturing phase.

Available in Safari 5.1 and later.

TARGETING_PHASE

The targeting phase.

Available in Safari 5.1 and later.