I do not understand why this does not work. I have a test.htm file sitting on my desktop that looks like this:
<html><head> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]} }); </script> <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full"></script></head> <body> This is $x^2$ </body></html>
and I have a webview that downloads this from my desktop via
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"file:///Users/john/Desktop/test.htm"]]];
which works great. Page loading is done by javascript MathJax and that $ x ^ 2 $ turns into a cool math script.
However, if I try to do this:
[[webView mainFrame] loadHTMLString:@"<html><head><script type=\"text/x-mathjax-config\">MathJax.Hub.Config({tex2jax: {inlineMath: [[\"$\",\"$\"],[\"\\\\(\",\"\\\\)\"]]}});</script><script type=\"text/javascript\" src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full\"></script></head><body>This is $x^2$</body></html>" baseURL:[NSURL URLWithString:@"file:///"]];
which loads the exact same web page after newlines are killed and \ replaced by "\" and "replaced by" \ ", JavaScript does not start and I just see plain text. This is $ x ^ 2 $ without mappings of $ x ^ 2 $ via MathJax.
Is there some secret command "no really webview, do javascript for me" that I am missing?
source share