16 Interactivity

16.1 Links: the <a> element

SVG provides an <a> element (??? exactly like HTML's <a> element?) to indicate those parts of the drawing which when clicked on will cause the current browser frame to be replaced by the contents of the URL specified in the href attribute.

The <a> element is an Xlink. (??? more precise language needed) (Note that the XLink specification is currently under development and is subject to change. The SVG working group will track and rationalize with XLink as it evolves.)

The following is an example of a hyperlink attached to a path (which in this case draws a triangle):

<a xml:link="simple" show="embed" actuate="auto" href="http://www.w3.org">
  <p d="M 0 0 L 200 0 L 100 200 Z"/>

If the path is clicked on, then the current browser frame will be replaced by the W3C home page.

16.2 Event Handling

Any <g>, <image>, <path>, <text> or vector graphic shape (such as a <rect>) can be assigned any of the following standard HTML event handlers:

Mouse Events

Keyboard Events

State Change Events (only applicable to outermost <g> elements which are to be mapped into a rectangula region/viewport)

Additionally, SVG's scripting engine needs to have the altKey, ctrlKey and shiftKey properties available.