我正在使用以下MathJax应用程序代码。 http://cs.jsu.edu/wordpress/?p=498#comment-217在Android 4.4上加载资源文件时未捕获到ReferenceError
在下面的函数中,我试图从资产目录加载文件。
public static boolean makeMathView_new(WebView webview) {
webview.getSettings().setRenderPriority(RenderPriority.HIGH);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadDataWithBaseURL("http://bar", "<script type='text/x-mathjax-config'>"
+"MathJax.Hub.Config({ messageStyle: 'none', showMathMenu: false, jax: ['input/TeX','output/HTML-CSS'], "
+"extensions: ['tex2jax.js'],"
+ "'HTML-CSS': { scale: 100 },"
+"TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'] } });</script>"
+"<script type='text/javascript' src='file:///android_asset/MathJax/MathJax.js'></script>"
+ "<span id='math'></span>","text/html","utf-8", "");
return true;
}
在Android 4.4模拟器上运行时,出现以下错误。
V/WebViewChromium(1342): Binding Chromium to the background looper Looper{b1da1340}
I/chromium(1342): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserProcessMain(1342): Initializing chromium process, renderers=0
W/chromium(1342): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
E/chromium(1342): [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
E/chromium(1342): [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
E/chromium(1342): [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
E/chromium(1342): [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
E/chromium(1342): [ERROR:gpu_info_collector.cc(86)] gfx::GLSurface::InitializeOneOff() failed
I/chromium(1101): [INFO:CONSOLE(1)] "Uncaught ReferenceError: MathJax is not defined", source: http://bar/ (1)
更新:结合ksasq的建议后,这是我的新代码,但它仍然无法正常工作。
webview.loadDataWithBaseURL("http://bar", "<script type='text/x-mathjax-config'>"
+ "function setupMathJax() {"
+ "MathJax.Hub.Config({ messageStyle: 'none', showMathMenu: false, jax: ['input/TeX','output/HTML-CSS'], "
+"extensions: ['tex2jax.js'],'HTML-CSS': { scale: 100 },"
+"TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'] } });"
+ "}"
+ "</script>"
+ "<script type='text/javascript' src='file:///android_asset/MathJax/MathJax.js'></script>"
+ "<body onload='setupMathJax()'>"
+ "<span id='math'></span>"
+ "</body>"
,"text/html","utf-8", "");
谢谢,但它仍然没有工作。按照您的建议,我已经完成了代码更改。请检查我上面的新代码。 –
您是否尝试过使用远程调试来确保MathJax脚本正在加载?它可能有助于指出问题出在哪里。 (请参阅https://developers.google.com/chrome-developer-tools/docs/remote-debugging#debugging-webviews) – ksasq