我在加载页面后使用这样的函数将数据加载到WebView。控制台告诉innerHTML的更新值是什么,但在WebView上的更改不会显示。在浏览器控制台中一切都很好。
<script language="javascript" type="text/javascript">
function init_order() {
var elems = document.getElementById("body-id").getElementsByClassName("order_data");
if(arguments.length == elems.length){
console.log("Number of arguments is correct.");
}
else{
console.log("Incorrect number of arguments.");
console.log("Class Tag: "+elems.length);
console.log("Arguments: "+arguments.length);
}
for(i = 0; i < elems.length ; ++i){
var tag = elems[i];
var tagValue = elems[i].innerHTML;
if(tagValue.search("%@") != -1){
var replacedStr = tagValue.replace("%@",arguments[i]);
elems[i].innerHTML = replacedStr;
//console.log(arguments[i]);
console.log("value: "+elems[i].innerHTML);
}
}
// window.location.reload()
}
</script>