SVG <script> Element
Last Updated :
16 Jun, 2022
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:
html
<!DOCTYPE html>
< html >
< body >
< svg width="400" height="200"
< script type="text/javascript">
alert("GeeksforGeeks");
</ script >
</ svg >
</ body >
</ html >
|
Output:
Example 2:
html
<!DOCTYPE html>
< html >
< body >
< svg width="400" height="200"
< 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
Share your thoughts in the comments
Please Login to comment...