Uploaded html is working perfectly.
But html created and saved in app just shows the content with format.
In my case, the html content is not constant, some of context is received from server and processed in the app. As a sample, I put below content and saved as a html file in blocks, and loaded in webviewer after filesaved. Now the contents and format of text are visible .but neither button , nor href is replacing the h3 content on mobile.
<!DOCTYPE html>
<html>
<style>
.header {
/* Stick to the top */
position: sticky;
overflow: auto;
top: 0;
background:cyan
}
div.b {
word-wrap: normal;
}
</style>
<script type = "text/javascript">
const myObj = {
"Good":["Nice,Happy"],
"fable":["legend,story,parable"],
"ridiculed":["mocked"],
"pace":["walk"],
"beat":["defeat,pound"],
"fatigue":["tired,washout,weary"],
};
//<a href="javascript:findMeaning('Good')">Good</a>
function findMeaning(textval) {
var obj;
obj = JSON.parse(JSON.stringify(myObj));
document.getElementById("id01").innerHTML = obj[textval];
}
</script>
<body>
<header id="header"; class="header"><h3 id="id01">Click on the words to find synonyms</h3></header>
Have a <button onclick="findMeaning('Good')">Good</button> day ahead.<br><br>
The hare and the tortoise <a href="javascript:findMeaning('fable')">fable</a>.<br>
</body>
</html>
.header {
/* Stick to the top */
position: sticky;
overflow: auto;
top: 0;
background:cyan
}
div.b {
word-wrap: normal;
}
Is it because I'm opening it as a file, instead of opening it on localhost path?
What would be localhost path in this case?
I tried http://localhost/userText.html in above example as well, but it gave 404 Not found error.
if we load the usertext.html in webviewer under http path, it works with java script, else it loads as a read only display file
It works for http://localhost path but in mycase I have created and saved html within app itself. when filepath is used, webviewer just displays it without running script. What is the localhost path of user created file?
Are you testing with companion on a device, or using the AI2 emulator (the emulator probably has an outdated version of the webview component, with less built-in features - js/jquery/etc.)?
I'm testing with apk file on the phone.
I tried with above file:/// path and the html opened up but the hyperlinks are not working
From the link below I understand that browsers treat http:// and file:/// differently
In summary, file:/// will be treated as under FTP and hence hyperlinks/buttons dont work.
So, we need to know a way in which we can access locally created files using http://
or enable fileURLs using extensions Loading local web content on Android
I have just compiled an apk that copies an html file from assets to the ASD
Tested on Android 10 and 12. The javascript works on both and delivers the synonyms using the file:///... protocol
Also, I see in your blocks you are asking for WRITE_EXTERNAL_STORAGE permission (?)
Which Android version are you working with?
Initially it didnt work in NoFileHtml, but after I removed the comments in javascript and html (as hinted in NoFileHtml page) it started working. I tried now with native webviewer, and its working there as well. I guess it wasnt working earlier due to comments in javascript and html. If its so, can it be given a hint in Help document of webviewer?
And also please provide a hint that semicolons are also mandatory in javascript code,as webviewer parser doesn't insert them, hence it behaves essentially like a one-line code