Passing Values to Embedded SVG

To pass parameters to an SVG, use the <object> element with child <param> elements. Each <param> element should have name/value pairs with the 'name' and 'value' attributes; these will be exposed to the embedded SVG document. The actual values are not necessarily specified, and can be arbitrary strings, though there are a few formal parameter name/values. An example of the HTML markup is:

<object type="image/svg+xml" data="embeddedDoc.svg">
   <param name="color" value="orange" />
   <param name="label" value="some text" />
</object>
      

The code for the script to access these parameterized values in the embedded SVG might look like this:

var params = document.defaultView.frameElement.getElementsByTagName('param');
for ( var i = 0, iLen = params.length; iLen > i; i++ )
{
   var eachParam = params[ i ];
   var name = eachParam.getAttribute( 'name' );
   var value = eachParam.getAttribute( 'value' );
   //do something here with the values;
}