Composition.document.body.innerHTML="<%= replace(mailbody, VBCrLf, "") %>"
解决方案 »
- 折线图如何使用鼠标拖动
- 页面打印问题,求方法
- 新手请教代码
- javascript如何实现邮箱后缀域名规范化
- 关于innerHTML的 问题
- 文本框的值问题 100分 谢谢
- 关于刷新声音控制问题
- 请大家帮忙改一下这句话好吗??
- 发生间不可思议的事情,onmousedown,onmouseup,当第一次按下鼠标不能及时获得onmousedown的对象
- 请问如何在同一台机器上,同时装IE5, 5.5, 和6啊?
- 我下了一个菜单在.aspx页面里用,但在页面里这个滑动菜单会和页面上的控件重合,如何能解决呢?
- 如何让一个window.open的窗口在刚刚弹出的时候在最前面一段时间,比如说10秒,之后就可以失去焦点?
<p>sgsdgds</p>"
这中间明显有一个回车换行符, 现在就是用替换的方式把回车换行符换掉成:
"<p>asdasd</p><p>sgsdgds</p>"
VBCRLF是VBS里定义的一个常量, 就是指回车换行符 chr(10)&chr(13)若是用JS, 则是这样写:
Composition.document.body.innerHTML="<%= mailbody.replace(/\r\n/mg, "") %>"
Composition.document.body.innerHTML=strvalue.replace(/\r\n/mg,"")
比如果<input value="aaaa">如果数据库里的值是aa"aa,不处理就直接使用的话,就会产生失真。
对于产生失真或的产生错误的特殊字符,都要进行处理。Script里面的,可以这样调用
<%=CommStr.jsEncoder(yourString)%>/*
* Created by Seamus
* Updated on 2004-10-21 by JK
*
*/
package com.jk.util;public class CommStr
{
/**
*replace the old string to new string in the given destination string.
*/
public static java.lang.String strReplace(java.lang.String destStr, java.lang.String oldStr, java.lang.String newStr)
{
if(destStr==null)
return "";
String tmpStr = destStr;
int foundPos = tmpStr.indexOf(oldStr);
while (foundPos>=0)
{
tmpStr = tmpStr.substring(0,foundPos) + newStr + tmpStr.substring(foundPos + oldStr.length(),tmpStr.length());
foundPos = tmpStr.indexOf(oldStr,foundPos+newStr.length());
}
return tmpStr;
} /**
*Encode for HTML.
*/
public static String htmlEncoder(String str)
{
if(str==null || str.equals(""))
return "";
String res_str;
res_str=strReplace(str,"<","<");
res_str=strReplace(str,">","&rt;");
res_str=strReplace(str,"\"",""");
res_str=strReplace(str,"'","'");
return res_str;
} /**
*Encode for HTML-Text.
*/
public static String htmlTextEncoder(String str)
{
if(str==null || str.equals(""))
return "";
String res_str;
res_str=strReplace(str,"<","<");
res_str=strReplace(str,">","&rt;");
res_str=strReplace(str,"\"",""");
res_str=strReplace(str,"'","'");
res_str=strReplace(str," "," ");
res_str=strReplace(str,"\r\n","<br>");
res_str=strReplace(str,"\r","<br>");
res_str=strReplace(str,"\n","<br>");
return res_str;
} /**
*Encode for URL.
*/
public static String urlEncoder(String str) {
return java.net.URLEncoder.encode(str) ;
} /**
*Encode for XML.
*/
public static String xmlEncoder(String str)
{
if(str==null || str.equals(""))
return "";
String res_str;
res_str=strReplace(str,"&","&");
res_str=strReplace(res_str,"<","<");
res_str=strReplace(res_str,">",">");
res_str=strReplace(res_str,"\"", """);
res_str=strReplace(res_str,"\'", "´");
return res_str;
} /**
*Encode for SQL.
*/
public static String sqlEncoder(String str)
{
if(str==null || str.equals(""))
return "";
String res_str;
res_str=strReplace(str,"'","''");
return res_str;
} /**
*Encode for Javascript.
*/
public static String jsEncoder(String str)
{
if(str==null || str.equals(""))
return "";
String res_str;
res_str=strReplace(str,"'","\\'");
res_str=strReplace(str,"\"","\\\"");
res_str=strReplace(str,"\r\n","\\\n");
res_str=strReplace(str,"\n","\\\n");
res_str=strReplace(str,"\r","\\\n");
return res_str;
}}