Thank you for considering this post.I have a html file of containing lot of math formulas in single page, as shown below
<p id="p006_002"><span class="class_a">a</span> <math><mrow><mn>7</mn><mi>x</mi><mo>−</mo><mn>4</mn><mo>=</mo><mn>17</mn></mrow></math></p> <p id="p007_002"><span class="blue-no">b</span>
<math display='inline'><mrow><mfrac><mrow><mn>3</mn><mi>x</mi><mo>−</mo><mn>2</mn></mrow><mn>4</mn></mfrac><mo>+</mo><mn>5</mn><mo>=</mo><mn>1</mn></mrow></math></p>
<math display='inline'><mrow><mn>2</mn><mrow><mo>(</mo><mrow><mfrac><mrow><mn>4</mn><mi>x</mi></mrow><mn>5</mn></mfrac><mo>−</mo><mn>1</mn></mrow><mo>)</mo></mrow><mo>=</mo><mn>6</mn></mrow></math> </p>
The Mathjax link is provided as
<script type="text/javascript" src="mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
In Android Android 4.2.2 , When i use WebView.loadUrl("file"), MathJax get loaded , and formula getting generated, But When I use
WebView.loadDataWithBaseUrl("baseurl","file as string","text/html","utf-8");
Forumala fails to get rendered.I want these things to get work from Android 4.0.3.Please Help me to Solve this issue.Thank you
I found out a solution. But updating it so late. It may help others to solve this problem, if they are facing it in future.
For loading Inline mathjax with webview's loadDataWithBaseUrl .I have replaced all the file(css,js) etc references as complete path(example: "file:///),and I loaded html as
Webview.loadDataBaseWithUrl("http://bar","file:///<file path>","text/html","utf-8);
It is necessary to call mathJax on page finish.
Related
I do articles on blogs, but I want to know if this code can be simplified so that the page is faster without affecting other things
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- easd descargas texto -->
<ins class="adsbygoogle" style="display: block;" data-ad-client="ca-pub-xxxxxxxx" data-ad-slot="xxxxxxxxx" data-ad-format="link" data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Try wrapping it in window.addEventListener("DOMContentLoaded", () => {...});, which will wait for the HTML to load before executing that piece of JS.
There still might be a bit of lag while the advertisements load, but there's not much you can do as that depends on the advertisement. You're letting other code run on your site, so you have no control over what it is, only when it is loaded.
I got one strange behavior from JQM page.
I am using phonegap-android 4.4.2 with eclipse IDE.
Page code :
<html>
<head></head>
<body>
<div data-role="page" id="folfirstForm" data-dom-cache="true">
<link rel="stylesheet" href="../../css/follow_up.css">
<script src="../../js/addProdLine.js"></script>
<script type="text/javascript">
$(document).off("pageshow", "#folfirstForm").on("pageshow", "#folfirstForm", function() {
alert("First form loaded!");
AddElement();
});
</script>
----Some body----
</body>
</div>
</div>
</html>
You can see on code that I have put data-dom-cache="true" as per my requirement. I have also include the js file named as addProdLine.js which contains functions that i required, (for e.g. The AddElement() is from include file it self).
Now, when i am visiting this page first time all the functionality works very well. On second visit on same page I am getting the previous state of form which is expected as i have put data-dom-cache="true". But Might be due to data-dom-cache="true" my external js files are not being loaded on the second time visit on same page. I want, that on every visit ,my js file should run.
Jquery mobile only loads tag once when whole document is loaded. After the document is loaded if you will click on other links then only content part data-role=page will be refreshed through ajax along with data transition effect. Hence either add all your js script in a file and add it into head tag or stop loading other pages through ajax using following option:
<a href="#" data-ajax=”false”>Without Ajax</a>
But if you will disable content loading using ajax then link will work as it works in normal webpage and also transition effect will be not exist.
Edit:
One Alternate way could be: you can append some random values to the path of your JS files.
<script src="../../js/addProdLine.js?Q=<?php echo time(); ?>"></script>
I have such HTML
<body>
<p>https://www.google.com</p>
<p>foo#bar.com</p>
</body>
Is there any way to tell WebView to auto linkify content, and render like if it was:
<body>
<p>https://www.google.com</p>
<p>foo#bar.com</p>
</body>
Short answer: No. WebView is a web browser, so it will render a html page. Your html page does not include links, so why would WebView alter it?
Long Answer: You can intercept the page loading using a WebViewClient then inject a javascript that linkifies the page. There are tons of JQuery-based scripts around. But mind that this method won't be bullet-proof and will depend on the loaded page structure. For something as simple as your example it will be very easy, but if you add HTML5 , dynamic content, Iframes, asynchronous content ... things start to get complicated.
The Connection to the server was unsuccessful(file:///android-asset/www/index.html)
is showing when i run my android application.
please let me know how to resolve this issue.
For latest Cordova (4+) this a setting in config.xml:
e.g.
<preference name="LoadUrlTimeoutValue" value="70000"/>
Increases default timeout to 70 seconds (default is 20), reducing the chance of timing out.
Docs: https://cordova.apache.org/docs/en/latest/config_ref/index.html#preference
When loading a page, the amount of time to wait before throwing a
timeout error.
This may asked here many times..
This issue can fix by adding a timeout to the webview call (index.html). In your project_name.java class just add this
super.setIntegerProperty("loadUrlTimeoutValue", 5000);
And in Cordova latest, just use this to timeout
super.loadUrl(Config.getStartUrl(), 5000);
Also go through these so questions
Question1
Question2
UPDATE :
One more solution, try this
Create a main.html and put your code there, and in your index.html just redirect to main.html
<script>
window.location='./main.html';
</script>
This blog post from Robert Kehoe:
Seemed to be EASY to me
Made sense to me
WORKED for me
Rename your index.html to "main.html"
Create a new "index.html" and put the following content into it:
<!doctype html>
<html>
<head>
<title>the title</title>
<script>
window.location='./main.html';
</script>
<body>
</body>
</html>
Rebuild your app! No more errors!
Robert also said,
Another good idea is to give your application a “splash screen”, so that the user gets instant feedback that your app is loading/working, before it is fully ready.
The main problem for this issue is take more time to load your page.
yes it's can a hack to solve this issue, make a html page name
index.html and your existing index page name to be change as a
main.html or any other one give a redirection to this page like this
<script>
window.location='main.html';
</script>
am sure it's work very much
hey i think this error may come load multiple script in starting time so it will take more time.
so you set like this in your java...
super.loadUrl("file:///android_asset/www/index.html");
super.setIntegerProperty("loadUrlTimeoutValue", 600000);
reference1
reference2
There is the html source code of the targeted iframe page
<html>
......
<body>
......
<div id="XXX"><p>**target**</p>
<div><p>**target**</p><span>**target**</span><p>**target**</p></div>
<p></p>
</div>
</body>
......
what i am going to do is to retrieve the data of which id="XXX" to my project(which means the four target as shown),is it possible to get the result by the method getElementById() from existing android library?Or any better suggestions? Thanks for advance
You can create a javascript function that would pass data from the browser to the activity using a javascriptinterface if your viewing this in a webview or a class that extends a webview. Its a little hard to tell what your trying to accomplish from just the little bit of code and info you posted.
You can use Jsoup HTML parser for android.