I have this simple javascript code:
When I launch it from WebViewExtras.executeJavascript I have this error:
Using it from pc it works good.
If I put an 'alert(svgItem)' before the error I obtain: [object SVGElement]
But if I put 'alert(child)' the result is : undefined
It is very strange because on the PC the code works perfectly. Is it a bug of webview ?
Thank you
B4X:
function ColoraSolo(elemento,colore) {
var a = document.getElementById("svgObject");
var svgDoc = a.contentDocument;
var baz = getElementsByAttribute(svgDoc,"clrto","xxy1");
for (i = 0; i < baz.length; i++) {
var att = document.createAttribute("opacity");
att.value = 0;
baz[i].setAttributeNode(att);
}
var svgItem = svgDoc.getElementById(elemento);
var child = svgItem.children;
var att = document.createAttribute("opacity");
att.value = 0.4;
var attw = document.createAttribute("fill");
attw.value = colore;
var ricn = document.createAttribute("clrto");
ricn.value = "xxy1";
for (i = 0; i < child.length; i++) { //<<<------ Line 35
child[i].setAttributeNode(att);
child[i].setAttributeNode(attw);
child[i].setAttributeNode(ricn);
}
}
When I launch it from WebViewExtras.executeJavascript I have this error:
B4X:
Uncaught TypeError: Cannot read property 'length' of undefined in file:/// (Line: 35)
If I put an 'alert(svgItem)' before the error I obtain: [object SVGElement]
But if I put 'alert(child)' the result is : undefined
It is very strange because on the PC the code works perfectly. Is it a bug of webview ?
Thank you