首页 web前端 html教程 html 浏览器自动加上<pre>标签的详解

html 浏览器自动加上<pre>标签的详解

Jul 08, 2017 pm 01:49 PM
firefox html webkit

问题场景:

我在 A 页面点击了一个请求,新开一个页面(B),在后端 通过 HttpServletResponse.getWriter().write(html) 的方式,将信息写入到 新开的页面 B 里面;【题外话:这样做的原因是为了解决新开页面被浏览器拦截的问题】

但是在 IE6,7,8 ,ff 都没有问题;但是在chrome 里面,竟然在我新写的内容放在了

标签中;</p>
<p><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/194/2dca1e20198ed7fa37b2e8461817f576-0.jpg" class="lazy" alt="有图有真像"><br></p>
<p><strong>关于html <pre class="brush:php;toolbar:false">标签:<摘自:w3school></strong></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif"><span style="background-color:rgb(255,255,255)">pre 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。</span></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif"><pre class="brush:php;toolbar:false"> 标签的一个常见应用就是用来表示计算机的源代码。</p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif"><strong>关于问题的思考:</strong></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif">在发现这个问题,首先我想到的是:这应该是不同浏览器对于代码文本信息的处理方式不同,chrome是将我这个form表单当成文本显示在页面上了。而<span style="color:#ff0000">不是一个html格式的元素;所以解决了这个问题我想就应该万事大吉了。</span></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px"><span style="font-family:Verdana,Arial,Helvetica,sans-serif">这个时候,我想到了 html</span><span style="font-family:微软雅黑,Verdana,sans-serif,宋体"><span style="font-size:14px">meta信息的设置</span></span></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif"><span style="font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px"><span style="font-family:Tahoma; line-height:18px"><meta http-equiv="<span style="color:#ff0000">Content-Type</span>" content="</span><span style="font-family:Tahoma; line-height:18px"><span style="color:#ff0000">text/html</span></span><span style="font-family:Tahoma; line-height:18px"> ;char<a href="http://www.php.cn/code/8209.html" target="_blank">set</a>=utf-8"
 /> 这个<a href="http://www.php.cn/wiki/169.html" target="_blank">属性</a>的设置应该就可以解决问题。</span><br></span></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif"><span style="font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px"><span style="font-family:Tahoma; line-height:18px; background-color:rgb(255,255,255)">查了一下文档豁然开朗:</span></span></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif"><span style="font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px"><span style="font-family:Tahoma; line-height:18px"></span></span></p>
<p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:10px; font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px"><span style="padding:0px; margin:0px; color:rgb(229,51,51)"><span style="padding:0px; margin:0px; color:rgb(0,0,0); background-color:rgb(255,255,255)">1、text/html是html格式的正文 </span></span></p>
<p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:10px; font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px"><span style="padding:0px; margin:0px; color:rgb(229,51,51)"><span style="padding:0px; margin:0px; color:rgb(0,0,0); background-color:rgb(255,255,255)">2、text/plain是无格式正文</span></span></p>
<p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:10px; font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px">3、text/xml忽略xml头所指定编码格式而默认采用us-ascii编码</p>
<p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:10px; font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px"><span style="padding:0px; margin:0px; color:rgb(229,51,51)"><span style="padding:0px; margin:0px; color:rgb(0,0,0); background-color:rgb(255,255,255)">4、application/xml会根据xml头指定的编码格式来编码</span></span></p>
<p><strong>解决方法:</strong></p>
<p style="margin-top:12px; margin-bottom:0px; line-height:18px; font-family:Verdana,Arial,Helvetica,sans-serif"><span style="font-family:微软雅黑,Verdana,sans-serif,宋体; font-size:14px"><span style="font-family:Tahoma; line-height:18px"></span></span></p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>response.setHeader("Content-Type", "text/html");
登录后复制

以上是html 浏览器自动加上<pre>标签的详解的详细内容。更多信息请关注PHP中文网其他相关文章!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

HTML 中的表格边框 HTML 中的表格边框 Sep 04, 2024 pm 04:49 PM

HTML 表格边框指南。在这里,我们以 HTML 中的表格边框为例,讨论定义表格边框的多种方法。

HTML 中的嵌套表 HTML 中的嵌套表 Sep 04, 2024 pm 04:49 PM

这是 HTML 中嵌套表的指南。这里我们讨论如何在表中创建表以及相应的示例。

HTML 左边距 HTML 左边距 Sep 04, 2024 pm 04:48 PM

HTML 左边距指南。在这里,我们讨论 HTML margin-left 的简要概述及其示例及其代码实现。

HTML 表格布局 HTML 表格布局 Sep 04, 2024 pm 04:54 PM

HTML 表格布局指南。在这里,我们详细讨论 HTML 表格布局的值以及示例和输出。

HTML 输入占位符 HTML 输入占位符 Sep 04, 2024 pm 04:54 PM

HTML 输入占位符指南。在这里,我们讨论 HTML 输入占位符的示例以及代码和输出。

HTML 有序列表 HTML 有序列表 Sep 04, 2024 pm 04:43 PM

HTML 有序列表指南。在这里我们还分别讨论了 HTML 有序列表和类型的介绍以及它们的示例

在 HTML 中移动文本 在 HTML 中移动文本 Sep 04, 2024 pm 04:45 PM

HTML 中的文本移动指南。在这里我们讨论一下marquee标签如何使用语法和实现示例。

HTML onclick 按钮 HTML onclick 按钮 Sep 04, 2024 pm 04:49 PM

HTML onclick 按钮指南。这里我们分别讨论它们的介绍、工作原理、示例以及各个事件中的onclick事件。

See all articles