SVG provides an <a> element, analogous to like HTML's <a> element, to indicate hyperlinks; 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 uses Xlink. (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 a valid example of a hyperlink attached to a path (which in this case draws a triangle):
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG July 1999//EN" "http://www.w3.org/Graphics/SVG/svg-19990706.dtd"> <svg width="4in" height="3in"> <desc>This valid svg document draws a triangle which is a hyperlink </desc> <a href="http://www.w3.org"> <path d="M 0 0 L 200 0 L 100 200 z"/> </a> </svg>
This is the well-formed equivalent example:
<?xml version="1.0" standalone="yes"?> <svg width="4in" height="3in" xmlns = 'http://www.w3.org/Graphics/SVG/svg-19990706.dtd'> <desc>This well formed svg document draws a triangle which is a hyperlink </desc> <a xml:link="simple" show="replace" actuate="user" href="http://www.w3.org"> <path d="M 0 0 L 200 0 L 100 200 z"/> </a> </svg>
In both examples, if the path is clicked on, then the current browser frame will be replaced by the W3C home page.
Any <g>, <image>, <path>, <text> or vector graphic shape (such as a <rect>) can be assigned any of the following standard HTML event handlers:
Additionally, SVG's scripting engine needs to have the altKey, ctrlKey and shiftKey properties available.
The outermost <svg> element in an SVG document can have the optional attribute allow-zoom-and-pan, which takes the possible values of trueand false. If true, the user agent should allow the user to zoom in and pan around the given document. If false, the user agent should not allow the user to zoom and pan on the given document.