18.1 Specifying the scripting language

18.1.1 Specifying the default scripting language

The contentScriptType attribute
on the 'svg'
element specifies the default scripting language for
the given document fragment.

.
contentScriptType
= "%ContentType;"

Identifies the default scripting language for the
given document. This attribute sets the scripting language used to
process the value strings in event attributes.
The value %ContentType; specifies a
media type, per [RFC2045].
The default value is "text/ecmascript".Animatable: no.

18.1.2 Local declaration of a scripting language

18.2 The 'script' element

A 'script' element is equivalent to the 'script' element in HTML and
thus is the place for scripts (e.g., ECMAScript).
Any functions defined within any 'script' element have a "global" scope
across the entire current document.

Example script01
defines a function circle_click which is called
by the onclick event attribute
on the
'circle'
element.
The drawing below on the left is the initial image.
The drawing below on the right shows the result after clicking on the circle.

Note that this example demonstrates the use of the
onclick event attribute
for explanatory purposes. The example presupposes the presence of an input
device with the same behavioral characteristics as a mouse, which will not always
be the case. To support the widest range of users, the
onactivate event attribute should be used
instead of the onclick event attribute.

Mouse Events

Keyboard Events

State Change Events

onload
(The event is triggered at the point at which the user agent has fully
parsed the element and its descendants and is ready to act appropriately
upon that element, such as being ready to render the element to the
target device.
Referenced external resources that are required
must be loaded, parsed and ready to render before the event is triggered.
Optional external resources are not required to be ready for the event to be triggered.)

onresize
(only applicable to outermost 'svg' elements which are to be mapped
into a rectangular region/viewport.
Similar semantics to DOM level 2 resize event for HTML.)

onscroll
(only applicable to outermost 'svg' elements which are to be mapped
into a rectangular region/viewport.
Similar semantics to DOM level 2 scroll event for HTML.)

onunload
(only applicable to outermost 'svg' elements which are to be mapped
into a rectangular region/viewport)

onzoom
(only applicable to outermost 'svg' elements which are to be mapped
into a rectangular region/viewport)

A load
event is dispatched only to the element to which the event applies;
it is not dispatched to its ancestors.
For example, if an 'image'
element and its parent 'g'
element both have event listeners for load
events, when the 'image'
element has been loaded, only its event listener will be invoked. (The
'g'
element's event listener will indeed get invoked, but the invocation
will happen when the 'g'
itself has been loaded.)

Interface SVGZoomEvent

The zoom event handler occurs before the zoom event is processed.
The remainder of the DOM represents the previous state of the document.
The document will be updated upon normal return from the event handler.

The UI event type for a zoom event is:

zoom

The zoom event occurs when the user initiates an action which causes
the current view of the SVG document fragment to be rescaled.
Event handlers are only recognized on
'svg'
elements.