首页前端开发其他前端知识Html转换UBB程序

Html转换UBB程序

时间2024-02-01 10:48:02发布访客分类其他前端知识浏览1050
导读:收集整理的这篇文章主要介绍了Html转换UBB程序,觉得挺不错的,现在分享给大家,也给大家做个参考。 HtML转换程序function HtmlToubB(str { str = st...
收集整理的这篇文章主要介绍了Html转换UBB程序,觉得挺不错的,现在分享给大家,也给大家做个参考。 HtML转换程序function HtmlToubB(str) { str = str.replace(/\r/g,""); str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,""); str = str.replace(/]*?> ([\w\W]*?)/ig,""); str = str.replace(/]+href="([^"]+)"[^> ]*> (.*?)/ig,"\n[url=$1]$2[/url]\n"); str = str.replace(/]+color=([^ > ]+)[^> ]*> (.*?)/ig,"\n[color=$1]$2[/color]\n"); str = str.replace(/]+src="([^"]+)"[^> ]*> /ig,"\n[img]$1[/img]\n"); str = str.replace(//ig,"[$1b]"); str = str.replace(//ig,"[$1b]"); str = str.replace(//ig,"[$1u]"); str = str.replace(//ig,"[$1i]"); str = str.replace(/& nbsp; /g," "); str = str.replace(/& amp; /g,"& "); str = str.replace(/& quot; /g,"\""); str = str.replace(/& lt; /g,""); str = str.replace(/
/ig,"\n"); str = str.replace(/]*?> /g,""); str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2"); str = str.replace(/\n+/g,"\n"); return str; }

function trans(){ var str = ""; str = document.getElementById('edit').contentWindow.document.body.innerHTML; if (str.length == 0) { alert("无转换内容!请使用 Ctrl+V 把内容复制到下面的编辑框内"); return } document.getElementById('ReCode').value=HtmlToUBB(str); document.getElementById('insert').disabled=false} function doHtmlinsert() { if (document.getElementById('ReCode').value=="") { alert("你没有进行代码转换,无法插入."); return} opener.AddText(document.getElementById('ReCode').value) window.close()} function clearCode(){ document.getElementById('ReCode').value=""; }

function Start() { document.getElementById('edit').contentWindow.document.designMode = "on"; try { document.getElementById('edit').contentWindow.document.execCommand("undo", false, null); } catch (e) { alert("你的Mozilla浏览器不支持在线RichEditor"); } }

function ViewSource(Source){ var Html; if (Source){ document.getElementById('sCode').value = document.getElementById('edit').contentWindow.document.body.innerHTML; document.getElementById('edit').style.display="none"; document.getElementById('sCode').style.display=""; document.getElementById('tip').innerText="修改粘贴后的网页源代码 > > "; document.getElementById('tranButton').disabled="disabled" } else{ document.getElementById('edit').contentWindow.document.body.innerHTML = document.getElementById('sCode').value; document.getElementById('edit').style.display=""; document.getElementById('sCode').style.display="none"; document.getElementById('edit').contentWindow.document.designMode = "on"; document.getElementById('tip').innerText="请使用 Ctrl+V 把内容复制到这里 > > "; document.getElementById('tranButton').disabled=""} } body{ background:#688ABD; margin:2px; } label{ color:#fff; } th{ font-size:14px; font-family:verdana,宋体; font-weight:bold; color:fc6; text-align:left} #sCode{ width:400; height:150px; border:1px solid #1F2F47; margin-top:0px !important; margin-top:-1px; margin-bottom:0px !important; margin-bottom:-1px; } #ReCode{ width:400; height:150px; border:1px solid #1F2F47; font-size:12px; } #edit{ width:398; height:148px; border:1px solid #1F2F47; background:#fff; font-size:12px} .input{ border-top:1px solid #fff; border-right:1px solid #003; border-bottom:1px solid #003; border-left:1px solid #fff; background:#F4F7FB; } .tip{ color:#ffc; font-weight:bold; font-size:12px; font-family:宋体; }

Html转换UBB程序
查看源代码
请使用 Ctrl+V 把内容复制到这里 & gt; & gt;
转换输出代码 & gt; & gt;


[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

上一篇: PBlog2 公用JS代码下一篇:pjblog的ubbcodeasp文件猜你在找的正则表达式相关文章 去除内容中的html2022-04-16Python正则表达式保姆式教学详细教程2022-04-16十分钟上手正则表达式 上篇2022-04-16十分钟上手正则表达式 下篇2022-04-16深入浅出正则表达式中的边界\b和\B2022-04-16轻松入门正则表达式之非贪婪匹配篇详解2022-04-16轻松掌握正则表达式findall函数详解2022-04-16正则表达式用法详解2022-04-1636个正则表达式(开发效率提高80%)2022-04-16Python正则表达式指南 推荐2022-04-16 其他相关热搜词更多phpjavapython程序员loadpost-format-gallery

若转载请注明出处: Html转换UBB程序
本文地址: https://pptw.com/jishu/595300.html
JS:正则将首字单词转成大写 关于表格的正则表达式讨论(表格)

游客 回复需填写必要信息