edit.js
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:5k
- function AddText(NewCode) {
- document.all.sBody.value+=NewCode
- }
- function fontchuli(){
- if ((document.selection)&&(document.selection.type == "Text")) {
- var range = document.selection.createRange();
- var ch_text=range.text;
- range.text = fontbegin + ch_text + fontend;
- }
- else {
- document.all.sBody.value=fontbegin+document.all.sBody.value+fontend;
- document.all.sBody.focus();
- }
- }
- function format(what,opt) {
- switch(what)
- {
- case "formatblock":
- fontbegin="[h"+opt+"]";
- fontend="[/h"+opt+"]";
- break;
- case "fontname":
- fontbegin="[face="+opt+"]";
- fontend="[/face]";
- break;
- case "fontSize":
- fontbegin="[size="+opt+"]";
- fontend="[/size]";
- break;
- case "bold":
- fontbegin="[b]";
- fontend="[/b]";
- break;
- case "italic":
- fontbegin="[i]";
- fontend="[/i]";
- break;
- case "underline":
- fontbegin="[u]";
- fontend="[/u]";
- break;
- case "justifyleft":
- fontbegin="[align=left]";
- fontend="[/align]";
- break;
- case "justifycenter":
- fontbegin="[align=center]";
- fontend="[/align]";
- break;
- case "justifyright":
- fontbegin="[align=right]";
- fontend="[/align]";
- break;
- case "insertorderedlist":
- fontbegin="[list]";
- fontend="[/list]";
- break;
- case "indent":
- fontbegin="[indent]";
- fontend="[/indent]";
- break;
- case "forecolor":
- fontbegin="[color="+opt+"]";
- fontend="[/color]";
- break;
- case "fly":
- fontbegin="[fly]";
- fontend="[/fly]";
- break;
- case "move":
- fontbegin="[move]";
- fontend="[/move]";
- break;
- case "special":
- fontbegin="["+opt+"]";
- fontend="[/"+opt+"]";
- break;
- }
- fontchuli();
- }
- function create(what) {
- switch(what)
- {
- case "createlink":
- hyperlink();
- break;
- case "insertimage":
- image();
- break;
- case "email":
- email();
- break;
- case "flash":
- flash();
- break;
- case "light":
- glow();
- break;
- case "shadow":
- shadow();
- break;
- }
- }
- function hyperlink() {
- txt2=prompt("请输入需要加上超级链接的链接文字.n若欲显示超级链接地址,则不输入。","");
- if (txt2!=null) {
- txt=prompt("超级链接的URL,也支持形如:FTP://………的形式。","http://");
- if (txt!=null) {
- if (txt2=="") {
- AddTxt="[url]"+txt+"[/url]";
- AddText(AddTxt);
- } else {
- AddTxt="[url="+txt+"]"+txt2+"[/url]";
- AddText(AddTxt);
- }
- }
- }
- }
- function image() {
- txt=prompt("请输入图片的地址。http://为必填代码请勿删除。在任一网站里的图上点右键,选择“属性”可查看此图地址,输入此地址即可。","http://");
- if(txt!=null) {
- if (txt.substring(0,7).toLowerCase()=="http://")
- {
- AddTxt="[img]"+txt+"[/img]";
- AddText(AddTxt);
- }
- else{
- alert("你输入的不是正确的图片地址!")
- }
- }
- }
- function email() {
- txt2=prompt("请输入需要加上EMAIL链接的链接文字.n若欲显示EMAIL链接地址,则不输入。","我的EMAIL地址");
- if (txt2!=null) {
- txt=prompt("请输入Email地址。","");
- if (txt!=null) {
- if (txt2=="") {
- AddTxt="[email]"+txt+"[/email]";
- } else {
- AddTxt="[email="+txt+"]"+txt2+"[/email]";
- }
- AddText(AddTxt);
- }
- }
- }
- function flash() {
- txt=prompt("请输入FLASH的URL地址。http://为必填代码请勿删除。关于如何得到一个FLASH文件的URL地址的详细信息,请看论坛“帮助”。","http://");
- if(txt!=null) {
- if(txt.substring(txt.length-3,txt.length).toLowerCase()=="swf" && txt.substring(0,7).toLowerCase()=="http://"){
- AddTxt="[flash]"+txt+"[/flash]";
- AddText(AddTxt);
- }
- else{
- alert("你输入的不是正确的FLASH动画地址!")
- }
- }
- }
- function glow() {
- txt2=prompt("请输入文字的长度,颜色,边界大小。","255,red,2");
- if (txt2!=null) {
- txt=prompt("要产生效果的文字","发光文字");
- if (txt!=null) {
- if (txt2=="") {
- AddTxt="[glow=255,red,2]"+txt+"[/glow]";
- AddText(AddTxt);
- } else {
- AddTxt="[glow="+txt2+"]"+txt+"[/glow]";
- AddText(AddTxt);
- }
- }
- }
- }
- function shadow() {
- txt2=prompt("请输入文字的长度,颜色,边界大小。","255,red,2");
- if (txt2!=null) {
- txt=prompt("要产生效果的文字","阴影文字");
- if (txt!=null) {
- if (txt2=="") {
- AddTxt="[shadow=255,red,2]"+txt+"[/shadow]";
- AddText(AddTxt);
- } else {
- AddTxt="[shadow="+txt2+"]"+txt+"[/shadow]";
- AddText(AddTxt);
- }
- }
- }
- }
- function forecolor() {
- if (!Error()) return;
- var arr = showModalDialog("color.htm","color","dialogWidth:200pt;dialogHeight:225pt;help:0;status:0");
- if (arr != null) format('forecolor',arr);
- else document.all.sBody.focus();
- }
- function clearEdit(){
- document.all.sBody.value = "";
- document.all.sBody.focus();
- }