I am trying to load the following html as a string into a webview:
<html>
<head>
<script>
function foo() {
// test.
}
</script>
</head>
<body>
<p>hi.</p>
</body>
</html>
------------------------------
String content = readAboveContentIntoString();
WebView webview = ...;
webview.loadData(content, "text/html", "utf-8");
I get the following message from the webview console:
Uncaught SyntaxError: Unexpected end of input
If I remove the "// test." comment, I don't get the syntax error. It's as if the webview is stripping newlines, and so the function body is applying the comment to the closing brace like so:
function foo() { // test. }
Can anyone else repro this? I thought maybe my readAboveContentIntoString() was stripping newlines, but tested and it is not. I'm using android 4.4.4.
Thanks
-- Edit ---
Also, a block comment works fine in place of the line comment:
/* test. */