Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

A SVG 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.

Usage context

Permitted contentAny elements or character data


The following code snippet demonstrates the use of the SVG script tag. In this code, we use JavaScript to change the radius of the SVG <circle> element.

<svg width="100%" height="100%" viewBox="0 0 100 100"
  <script type="text/javascript">
    // <![CDATA[
    function change(evt) {
      var target =;
      var radius = target.getAttribute("r");

      if (radius == 15) {
        radius = 45;
      } else {
        radius = 15;

   // ]]>

  <circle cx="50" cy="50" r="45" fill="green"
          onclick="change(evt)" />

Live result:


Global attributes

Specific attributes

DOM interface

This element implements the SVGScriptElement interface.


Specification Status Comment
Scalable Vector Graphics (SVG) 2
The definition of '<script>' in that specification.
Working Draft  
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of '<script>' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.5 (1.8) 9.0 9.0 3.0.4
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 3.0 1.0 (1.8) Not supported (Yes) 3.0.4

The chart is based on these sources.

See also


 このページの貢献者: Sebastianz, kscarfone, Jeremie, Sheppy, rshetty, Manuel_Strehl, syssgx
 最終更新者: Sebastianz,