I am trying to use javascript and html5 to create a HMI for a project. In this first experiment i just want to change a text element in the svg document.
The svg object is defined in html like this:
<object id="image-svg" width="800" height="800" type="image/svg+xml" data="image.svg"></object>
This script:
function update_txtPv( val )
{
var imageSvgDoc = document.getElementById( "image-svg" ).contentDocument;
var txtPv = imageSvgDoc.getElementById( "txtPv" );
txtPv.textContent = val;
}
update_txtPv( "test" );
gets called once when the page loads.
Problem is that if I refresh the page ten times it only sets the text object to "test" about three of the times.
if I add an alert( "something" ); in the beginning of the function it works.
What is going on?
//John