我有一个 WebView
因为我已经加载了MathJax.js使用以下代码。
webView.loadDataWithBaseURL("","<script type='text/javascript' "
+ "src="+ url +"></script>"
+ "<span id='math'></span>"
/**
I want set text dynamically for above span tag
using following script.
**/
+ "<script type='text/javascript'>"
+ "document.getElementById(\"math\").innerHTML='\\\\["+doubleEscapeTeX(question.getQuestion())+"\\\\]';"
+ "</script>","text/html","utf-8","");
我想为上面的 <span>
动态设置文本使用以下标签 <script>
.
<script type='text/javascript'>
document.getElementById(\"math\").innerHTML='\\\\"+doubleEscapeTeX(question.getQuestion())+"\\\\]';"
</script>
如何使用 WebView
重新设置? ?
In short, i want to load javascript only once and other content load dynamically every time.
我们将不胜感激。
最佳答案
尝试使用
"$(function() { ... });"
或
"$(document).ready(function() { ... });".
<script type='text/javascript'>
$(document).ready(function() {
document.getElementById(\"math\").innerHTML='\\\\"+doubleEscapeTeX(question.getQuestion())+"\\\\]';"
});
</script>
关于javascript - Android WebView getElementById ('math')不能动态工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25306250/