简体   繁体   English

html页面不会在android api 8 webview中呈现,但在浏览器中可以

[英]html page will not render in android api 8 webview but OK in browser

I am working on a simple android app to display a different page for each day of the week. 我正在使用一个简单的android应用程序来显示一周中的每一天的不同页面。

I have an HTML file I generated with Microsoft Word by saving as Web Page Filtered. 我有一个使用Microsoft Word通过保存为“网页过滤”生成的HTML文件。

It renders OK in a WebView with API 17. 它将在使用API​​ 17的WebView中呈现为“正常”。

It renders OK in the Browser on API 8. 它在API 8的浏览器中呈现为OK。

But, in the WebView in API 8, it gets reported as "Web page not available" and then apparently it lists the text of the reply after 但是,在API 8的WebView中,它被报告为“网页不可用”,然后显然列出了回复后的文本

"The Web page at " blah "might be temporarily down, 
or..(more misdirection to useless impossibilities)"

where blah looks like the correct characters of the HTML I want it to render (not a URL at all)! 在哪里看起来像我要呈现的HTML的正确字符(根本不是URL)! I wish I could paste that... well maybe I can if I stop in the debugger..... 我希望我可以粘贴...好吧,如果我停在调试器中也可以.....

The HTML includes what I think is a big comment. HTML包含了我认为很重要的内容。 If I edit out that comment manually, then it renders OK in API 8 WebView! 如果我手动删除该注释,那么它将在API 8 WebView中呈现为OK!

Is there some magic in this comment? 此评论中有魔术吗? Or does it violate some comment rule that Microsoft does not know about? 还是违反了Microsoft不知道的某些评论规则?

I appreciate any insight if you have seen and solved a similar problem. 如果您已经看到并解决了类似的问题,我将不胜感激。

I will paste the failing HTML: 我将粘贴失败的HTML:

<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 14 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
    {font-family:Calibri;
    panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
    {font-family:Consolas;
    panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin-top:0in;
    margin-right:0in;
    margin-bottom:10.0pt;
    margin-left:0in;
    line-height:115%;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
    {mso-style-link:"Plain Text Char";
    margin:0in;
    margin-bottom:.0001pt;
    font-size:10.5pt;
    font-family:Consolas;}
span.PlainTextChar
    {mso-style-name:"Plain Text Char";
    mso-style-link:"Plain Text";
    font-family:Consolas;}
p.msochpdefault, li.msochpdefault, div.msochpdefault
    {mso-style-name:msochpdefault;
    margin-right:0in;
    margin-left:0in;
    font-size:12.0pt;
    font-family:"Calibri","sans-serif";}
p.msopapdefault, li.msopapdefault, div.msopapdefault
    {mso-style-name:msopapdefault;
    margin-right:0in;
    margin-bottom:10.0pt;
    margin-left:0in;
    line-height:115%;
    font-size:12.0pt;
    font-family:"Times New Roman","serif";}
.MsoChpDefault
    {font-size:10.0pt;
    font-family:"Calibri","sans-serif";}
@page WordSection1
    {size:8.5in 11.0in;
    margin:1.0in 75.1pt 1.0in 75.05pt;}
div.WordSection1
    {page:WordSection1;}
-->
</style>

</head>

<body lang=EN-US>

<div class=WordSection1>

<p class=MsoPlainText><b><span style='font-size:28.0pt;font-family:"Courier New"'>Wednesday</span></b></p>

<p class=MsoPlainText><b><span style='font-size:28.0pt;font-family:"Courier New"'>Mothra</span></b><span
style='font-size:28.0pt;font-family:"Courier New"'> will be here today from
10:00 to 4:00</span></p>

<p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;</span></p>

</div>

</body>

</html>

That looks OK I guess! 我猜那看起来还行! (my first post here). (我在这里的第一篇文章)。

The java is simple, but it could be the problem I suppose: Java很简单,但可能是我想的问题:

  case QueryService.STATUS_FINISHED:
            String results = resultData.getString("results");
            // jcb changed
            // mResponseContent.setText(results);
            wv.loadData(results, "text/html", "utf-8");

Thanks to all! 谢谢大家!

使用此代码:

wv.loadDataWithBaseURL("", YOUR_HTML, "text/html", "UTF-8", "");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM