是否有可能使用< a>在< pre>标签内的标签。标签? [英] Is it possible to use an <a> tag within a <pre> tag?

查看:157
本文介绍了是否有可能使用< a>在< pre>标签内的标签。标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一些在网页上生成给定消息的遗留代码,但是它包含了一个< pre> 标记 - 我希望将一个链接(锚标签)就像这样:

 < pre>用户创建成功 - < a href ='/ View / User / 17'>点击此处< / a>查看用户个人资料< / pre> 

但我想因为它的< pre> 标记它会忽略其中的标记。有没有办法解决这个问题?



APOLOGIES



浪费了每个人的时间 - 发生这种情况的原因是因为我使用 ModelState.AddModelError (在ASP.NET MVC中)来设置错误消息, HTML编码你给它的消息(我使用了Chrome的元素检查器,它显示了HTML解码的版本,因此引起混淆) 解析方案

内容(例如< a> )可在< pre> 中获得。



参考文献:




Im working with some legacy code that generates a given message on a webpage but surrounds it with a <pre> tag - I was hoping to put a link (anchor tags) within it like this:

<pre>User created successfully - <a href='/View/User/17'>click here</a> to view the users profile</pre>

But I think because its a <pre> tag it ignores tags within it. Is there any way around this?

APOLOGIES

Im really sorry to have wasted everyone's time - the reason why it was happening was due to the fact that I was using ModelState.AddModelError (in ASP.NET MVC) to set the error message, which automatically HTML encodes the message you give it (I used Chrome's element inspector which shows the HTML decoded version, hence the confusion)

解决方案

Phrasing content (such as <a>) is allowed in <pre>.

References:

这篇关于是否有可能使用&lt; a&gt;在&lt; pre&gt;标签内的标签。标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆