易截截图软件、单文件、免安装、纯绿色、仅160KB

将 文本格式标记 转化为 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("&nbsp;", "   ");
            oldStr = oldStr.Replace("&lt;", "<");
            oldStr = oldStr.Replace("&gt;", ">");
            oldStr = oldStr.Replace("<br/>", "\n");
            oldStr = oldStr.Replace("&nbsp;&nbsp;&nbsp;", "\t");
            oldStr = oldStr.Replace("&quot;", "\"");
            return newStr;
        }
这时在
用文本可视化查看  为  :<FONT color=#e6421a>hgjghj</FONT>
用HTML可视化查看  为:hgjghj
此时前台控件显示的就将是hgjghj (保留样式,不显示标记)
如果要去掉所有标记,同时去掉样式, 只要在经过上面的方法处理之后,在经过以下方法即可
function RemoveHTML(strText)
          {
            var regEx = /<[^>]*>/g;
   &nb


相关文档:

html学习(常用属性)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; char ......

Sql版本除去html并截取指定长度的字符串

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 ......

搜索之路 c#从html中提取文本

直接封装成一个类的,用起来还挺方便的
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 ......

TextBox 超链接替换成HTML超链接形式


            string tent = this.TextBox_info.Text.Replace("<", "&lt;").Replace(">", "&gt;").Replace(" ", "&nbsp;&nbsp;&nbsp;&nbsp;").Trim().Replace("\n", "<br/>");
       & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号