[RIA]编辑框里过滤各种特殊字符 |
<!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> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head>
<body bgcolor="#FF0000"> <script type="text/javascript"> <!-- function Edit() { var text = document.getElementById("div1"); var obj = document.getElementById("text1"); obj.value = text.innerHTML.replace(/(<br>| |&|<|>)/gi, function(a, b){ switch(b.toLowerCase()){ case "<br>": return "\r\n"; case " ": return " "; case "&": return "&"; case "<": return "<"; case ">": return ">"; } });; } function Done() { var text = document.getElementById("div1"); var obj = document.getElementById("text1"); text.innerHTML = obj.value.replace(/(&|<|>| |\r\n|\n)/g, function(a, b){ switch(b){ case "\r\n": case "\n": return "<br>"; case " ": return " "; case "&": return "&"; case "<": return "<"; case ">": return ">"; } }); } //--> </script><div id="div1">123123</div><textarea id="text1" style="width:600px; height:300px; overflow:auto; border:0px;">haha haha</textarea> <button onclick="Edit()">Edit</button> <button onclick="Done()">Done</button> </body></html>
|
|
|  .: 公告
|
« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
| .: 我的分类(专题) |  .: 最新日志 .: 最新回复
| 
blog名称:up forever 日志总数:130 评论数量:274 留言数量:4 访问次数:1946591 建立时间:2006年5月25日 |
|  .: 留言板 |  .: 链接 |

|