将 文本格式标记 转化为 html格式标记
在做一个聊天记录的时候遇到这样一个问题,之前写入的带有特殊标记的文字,在写入数据库再读取的时候,带有html标记,
在后台调试,设置断点,取出的数据(hgjghj)(包括样式),
用文本可视化查看 为 :<FONT color=#e6421a>hgjghj</FONT>
用HTML可视化查看 为:<FONT color=#e6421a>hgjghj</FONT>
在js中利用 document.getElementById ("newmessage").innerHTML = str;将str赋值给newmessage控件时,显示的一直是:<FONT color=#e6421a>hgjghj</FONT>
如果要去掉font标记 ,只显示hgjghj
解决方法如下:
将str赋值给控件前,先经过以下方法处理。
public static string newStr(string oldStr)
{
oldStr = oldStr.Replace(" ", " ");
oldStr = oldStr.Replace("<", "<");
oldStr = oldStr.Replace(">", ">");
oldStr = oldStr.Replace("<br/>", "\n");
oldStr = oldStr.Replace(" ", "\t");
oldStr = oldStr.Replace(""", "\"");
return newStr;
}
这时在
用文本可视化查看 为 :<FONT color=#e6421a>hgjghj</FONT>
用HTML可视化查看 为:hgjghj
此时前台控件显示的就将是hgjghj (保留样式,不显示标记)
如果要去掉所有标记,同时去掉样式, 只要在经过上面的方法处理之后,在经过以下方法即可
function RemoveHTML(strText)
{
var regEx = /<[^>]*>/g;
&nb
相关文档:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
Go
----截取字符串,并出去html
create FUNCTION [dbo].[CutString] (@str varchar(1000),@length int)
RETURNS varchar(1000) AS
BEGIN
declare @mainstr varchar(1000)
declare @substr varchar(1000)
if(@str is not null or @st ......
<@Aattention Content="本Blog原创文章,转载或引用请注明转载"
from="Robby.cnblogs.com"@>
由于自己的搜索引擎中做到了这一块内容,所以今天说说如何抓取网页数据、分析并且去除Html标签,给大家提供一个参考。我的平台是Visual
Studio2005,C#。
& ......
直接封装成一个类的,用起来还挺方便的
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text ......
到底元素的id和name有什么区别阿?为什么有了id还要有name呢?!
id的主要用途:
在客户端页面作为对象的唯一表示,同一个页面中不允许出现多个相同的id.可以使用javascript的document.getElementById('id')来获取对象.
name的具体用途有:
用途1:
作为可与服务器交互数据的HTML元素的服务器端的标示,比如input、sele ......