Advertisement
dRxL

SVG parameter dynamism

Apr 3rd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.93 KB | None | 0 0
  1. <?xml version="1.0" standalone="no"?>
  2. <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  3. <svg xmlns="http://www.w3.org/2000/svg" width="6cm" height="5cm" viewBox="0 0 600 500" version="1.1" onload="set_col(evt)">
  4.     <desc>Example script, set color by URI parameter
  5.   </desc>
  6.     <!-- ECMAScript to change the radius with each click -->
  7.     <script type="application/ecmascript"><![CDATA[
  8.  
  9.     function set_col(evt){
  10.         // debugger
  11.         var params = document.location.search.slice(1).split('&')
  12.         for (i = 0; i < params.length; i++){
  13.             if (params[i].indexOf("color=")==0){
  14.                 document.getElementById("cc").setAttribute('fill',params[i].split('=')[1])
  15.             }
  16.         }
  17.     }
  18.  
  19.  ]]></script>
  20.     <!-- Outline the drawing area with a blue line -->
  21.     <rect x="1" y="1" width="598" height="498" fill="none" stroke="blue"/>
  22.     <!-- Act on each click event -->
  23.     <circle id="cc" cx="300" cy="225" r="200" fill="blue"/>
  24. </svg>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement