The script element indicate links to a client-side language.

class svgwrite.container.Script(href=None, content='', **extra)

The script element indicate links to a client-side language. This is normally a (also known as Hyperlinks or Web links).

The remote resource (the source of the script) is defined by a <URI> specified by the XLink xlink:href attribute. The remote resource must be a text-file that contains the script contents. This script can be used within the SVG file by catching events or adding the mouseover/mousedown/ mouseup elements to the markup.

Script.__init__(href=None, content='', **extra)
  • href (string) – hyperlink to the target resource or None if using content
  • content (string) – script content
  • extra – additional attributes as keyword-arguments

Use href or content, but not both at the same time.


Append content to the existing element-content.

Best place for the script element is the defs attribute of the Drawing class:


SVG Attributes

  • typestring

    Identifies the scripting language for the given script element. The value content-type specifies a media type, per MIME. If a type is not provided, the value of contentScriptType on the svg element shall be used, which in turn defaults to 'application/ecmascript'. If a script element falls outside of the outermost svg element and the type is not provided, the type must default to 'application/ecmascript'

  • externalResourcesRequiredbool

    False: if document rendering can proceed even if external resources are unavailable else: True

  • xlink:hrefstringhref parameter

  • xlink:show'new|replace'

  • xlink:acuate'onRequest'

    This attribute provides documentation to XLink-aware processors that an application should traverse from the starting resource to the ending resource only on a post-loading event triggered for the purpose of traversal.