UBB 编辑器演示 (兼容 IE, Opera, Firefox) By shawl.qiu
UBB 编辑器演示 (兼容 IE, Opera, Firefox) By shawl.qiu
By
admin
at 2007-10-07
0人收藏 • 1217人看过
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> /*-------------------------------------------------------*\ * UBB 编辑器演示 (兼容 IE, Opera, Firefox) By shawl.qiu * 参数说明: * target: 字符串, UBB 主编辑域 ID * markup: 字符串, UBB 标签 \*-------------------------------------------------------*/ function ubbTag(target, markup){ var txa=document.getElementsByName(target)[0]; txa.focus(); var strEnd=markup.replace(/\[/ig,'[/'); if (strEnd.indexOf('=')>-1){ strEnd=strEnd.replace(/(.*?)\=.*?\]/,'$1]'); } if(document.selection&&document.selection.type== "Text"){ // IE, Opera var oStr=document.selection.createRange(); oStr.text=markup+oStr.text+strEnd; } else if(window.getSelection&&txa.selectionStart>-1) { // Netscape var st=txa.selectionStart; var ed=txa.selectionEnd; txa.value=txa.value.substring(0,st)+markup+ txa.value.substring(st,ed)+strEnd+ txa.value.slice(ed); } else { txa.value+=markup+strEnd; } } // shawl.qiu script //]]> </script> <form action="" method="post" name="ubbForm" id="ubbForm"> <select onchange="ubbTag('content', '['+this.value+']')"> <option value="h6">h6</option> <option value="h5">h5</option> <option value="h4">h4</option> <option value="h3">h3</option> <option value="h2">h2</option> <option value="h1">h1</option> <option value="h1" selected="selected">font size</option> </select> <select onchange="ubbTag('content', '<FONT COLOR='+this.value+'>')"> <option value="black">color</option> <option value="black" style="background-color:black; color:#FFFFFF;">black</option> <option value="blue" style="background-color:blue; color:#FFFFFF;">blue</option> <option value="fuchsia" style="background-color:fuchsia; color:#FFFFFF;">fuchsia</option> <option value="gray" style="background-color:gray; color:#FFFFFF;">gray</option> <option value="green" style="background-color:green; color:#FFFFFF;">green</option> <option value="lime" style="background-color:lime;">lime</option> <option value="maroon" style="background-color:maroon; color:#FFFFFF;"> maroon </option> <option value="navy" style="background-color:navy; color:#FFFFFF;">navy</option> <option value="olive" style="background-color:olive; color:#FFFFFF;">olive</option> <option value="orange" style="background-color:orange; color:#FFFFFF;">orange</option> <option value="purple" style="background-color:purple; color:#FFFFFF;">purple</option> <option value="red" style="background-color:red; color:#FFFFFF;">red</option> <option value="silver" style="background-color:silver; color:#FFFFFF;">silver</option> <option value="teal" style="background-color:teal; color:#FFFFFF;">teal</option> <option value="white" style="background-color:white;">white</option> <option value="yellow"style="background-color:yellow;">yellow</option> </select> <input type="button" value="url" onclick="ubbTag('content', '<A TARGET=_blank HREF=')"/> <input type="button" value="img" onclick="ubbTag('content', '>')"/> <input type="button" value="img" onclick="ubbTag('content', '[img]')"/> <input type="button" value="email" onclick="ubbTag('content', '[email]')"/> <input type="button" value="code" onclick="ubbTag('content', '<FORM><span><TEXTAREA cols=70 rows=10 name=CBGZS>')" /> <input type="button" value="quote" onclick="ubbTag('content', '<blockquote>')"/> <input type="button" value="cite" onclick="ubbTag('content', '[cite]')"/> <input type="button" value="linenum" onclick="ubbTag('content', '[linenum]')"/> <input type="button" value="b" onclick="ubbTag('content', '<b>')"/> <input type="button" value="left" onclick="ubbTag('content', '[align=left]')"/> <input type="button" value="center" onclick="ubbTag('content', '[align=center]')"/> <input type="button" value="right" onclick="ubbTag('content', '[align=right]')"/> <input type="button" value="textarea" onclick="ubbTag('content', '[textarea]')"/> <input type="button" value="pre" onclick="ubbTag('content', '[pre]')"/> <input type="button" value="xmp" onclick="ubbTag('content', '[xmp]')"/> <input type="button" value="sub" onclick="ubbTag('content', '[sub]')"/> <input type="button" value="sup" onclick="ubbTag('content', '[sup]')"/> <input type="button" value="abbr" onclick="ubbTag('content', '[abbr]')"/> <input type="button" value="address" onclick="ubbTag('content', '[address]')"/> <input type="button" value="dl" onclick="ubbTag('content', '[dl][dd]')"/> <input type="button" value="dt" onclick="ubbTag('content', '[dt]')"/> <input type="button" value="dd" onclick="ubbTag('content', '[dd]')"/> <input type="button" value="nl" onclick="ubbTag('content', '[nl][li]')"/> <input type="button" value="ol" onclick="ubbTag('content', '[ol][li]')"/> <input type="button" value="ul" onclick="ubbTag('content', '[ul][li]')"/> <input type="button" value="li" onclick="ubbTag('content', '[li]')"/> <input type="button" value="floatleft" onclick="ubbTag('content', '[float=left]')"/> <input type="button" value="floatright" onclick="ubbTag('content', '[float=right]')"/> <input type="button" value="tagLink" onclick="ubbTag('content', '[taglink]')"/> <input type="button" value="glLink" onclick="ubbTag('content', '[gllink]')"/> <br/> <textarea name="content" cols="80" rows="10">aaaaaaaaaa</textarea><br/> <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Reset" value="Reset" /> </form>
提示:你可先修改部分代码,再按运行
其它类别
登录后方可回帖
1 个回复 | 最后更新于 2007-10-28
e719
2007-10-28
#1
首页
话题广场
搜索
登 录
登 录
现在注册
桌面模式
登 录
现在注册