SVG stands for Scalable Vector Graphic. It can be used to make graphics and animations like in HTML canvas.
The SVG <script> element allows adding scripts to an SVG document.
Syntax:
<script>
// Script Here
</script>
Attributes:
- crossorigin: This defines the COS settings.
- href: This defines the href URL to load.
- type: Type of language or script to use.
- Global Attributes: Some global attributes used like core attributes and styling attributes, etc.
Example 1:
<!DOCTYPE html>
<html>
<body>
<svg width="400" height="200"
xmlns="http://www.w3.org/2000/svg">
<script type="text/javascript">
alert("GeeksforGeeks");
</script>
</svg>
</body>
</html>
Output:
Example 2:
<!DOCTYPE html>
<html>
<body>
<svg width="400" height="200"
xmlns="http://www.w3.org/2000/svg">
<script>
console.log(
"GeeksforGeeks: Computer Science Portal for Geeks");
</script>
</svg>
</body>
</html>
Output:
Supported Browsers: The following browsers are supported by this SVG element:
- Chrome 1 and above
- Edge 12 and above
- Firefox 1.5 and above
- Safari 3.1 and above
- Internet Explorer 9 and above
- Opera 9 and above