c# WebBrowser Different behaviour on InvokeScript and inline
<p>i've got a tool which is uses HTML+SVG+JS for telemetry displaying. A need a special effects like rotation animation.</p>

<p>i've got a simple code on JS:</p>

<pre><code>function process_tlm(tlm)
{
    tlm = JSON.parse(tlm)

    var rects = document.getElementsByTagName("rect");
    for (var i = 0; i &lt; rects.length; i++) 
    {
        if (rects[i].textContent)
        {
            var objectinner= null;
            if (objectinner = JSON.parse(rects[i].textContent))
            {
                if (objectinner.tlm_point == tlm.name)
                {
                    if (objectinner.actions!=null &amp;&amp; tlm.value in objectinner.actions)
                    {
                    eval("rects[i]."+objectinner.actions[tlm.value])
                    }
                    else if (objectinner.animate!=null)
                    {
                    external.log("animate!=null "+rects[i].id+" "+tlm.name+" "+tlm.value);
                    dir = 1;
                    if (tlm.value&lt;0) 
                    {
                    dir = -1;
                    }
                    var speed  = 0;
                    if (tlm.value!=0)
                    {
                    speed = Math.abs(1000/tlm.value);
                    }
                    addRotateTransform(rects[i].id,speed,dir);
                    }
                }

            }
        }
}
}



function addRotateTransform(target_id, dur, dir)
{
var svgNS="http://www.w3.org/2000/svg";
var svgDoc = document;
var my_element = svgDoc.getElementById(target_id);
var a = svgDoc.createElementNS(svgNS, "animateTransform");
var bb = my_element.getBBox();
var cx = bb.x + bb.width/2;
var cy = bb.y + bb.height/2;
a.setAttributeNS(null, "attributeName", "transform");
a.setAttributeNS(null, "attributeType", "XML");
a.setAttributeNS(null, "type", "rotate");
a.setAttributeNS(null, "dur", dur + "s");
a.setAttributeNS(null, "repeatCount", "indefinite");
a.setAttributeNS(null, "from", "0 "+cx+" "+cy);
a.setAttributeNS(null, "to", 360*dir+" "+cx+" "+cy);
my_element.appendChild(a);
a.beginElement();
}
</code></pre>

<p>when i place process_tlm() call inside html document it works:</p>

<pre><code>process_tlm('{"name":"z2i10-4_SRW1_meas","value":"-148"}');
</code></pre>

<p>but then i'm trying to to the same from C# code using:</p>

<pre><code>webBrowser1.Document.InvokeScript("process_tlm", new object[] { s });
</code></pre>

<p>i'm getting an error: </p>

<pre><code>"'a' is not support for beginElement()"
</code></pre>

<p>How can i get it works right?</p>