Note that there are some explanatory texts on larger screens.

plurals
  1. POWebView doesn't run JavaScript given in loadHTMLString
    primarykey
    data
    text
    <p>I don't understand why this isn't working. I have a test.htm file sitting on my desktop that looks like this:</p> <pre><code>&lt;html&gt;&lt;head&gt; &lt;script type="text/x-mathjax-config"&gt; MathJax.Hub.Config({ tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]} }); &lt;/script&gt; &lt;script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full"&gt;&lt;/script&gt;&lt;/head&gt; &lt;body&gt; This is $x^2$ &lt;/body&gt;&lt;/html&gt; </code></pre> <p>and I have a WebView that is loading this from my desktop via</p> <pre><code>[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"file:///Users/john/Desktop/test.htm"]]]; </code></pre> <p>which works fine. The page loads, the MathJax javascript runs, and that $x^2$ is turned into a nice typeset math script. </p> <p>However, if I try to do this:</p> <pre><code>[[webView mainFrame] loadHTMLString:@"&lt;html&gt;&lt;head&gt;&lt;script type=\"text/x-mathjax-config\"&gt;MathJax.Hub.Config({tex2jax: {inlineMath: [[\"$\",\"$\"],[\"\\\\(\",\"\\\\)\"]]}});&lt;/script&gt;&lt;script type=\"text/javascript\" src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full\"&gt;&lt;/script&gt;&lt;/head&gt;&lt;body&gt;This is $x^2$&lt;/body&gt;&lt;/html&gt;" baseURL:[NSURL URLWithString:@"file:///"]]; </code></pre> <p>which loads <em>exactly</em> the same webpage after newlines are killed and \'s are replaced with "\" and "'s are replaced with '\"', the JavaScript fails to run, and I just see the plain text This is $x^2$ without the $x^2$ being rendered via MathJax.</p> <p>Is there some secret, "no really webview, please execute javascript for me" command that I am missing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload