UBB编辑器原来就这么简单

时间:2010-03-30 16:51:01  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读: *       [标签名称=参数][/标签名称] */function ubbaction(tag, val){ var tag = tag.toUpperCase(); if(typeof(val) == "undefined"){  val = ""; } if(val){  val = "=" + val; } 
  正文:<script>
/*
 * 功能:UBB编辑控制函数
 * 参数: tag 为标签名称 val 为标签参数
 * 返回:[标签名称=参数]修饰文字[/标签名称]
 *       [标签名称]修饰文字[/标签名称]
 *       [标签名称=参数][/标签名称]
 */
function ubbaction(tag, val){
 var tag = tag.toUpperCase();
 if(typeof(val) == "undefined"){
  val = "";
 }
 if(val){
  val = "=" + val;
 }
 
 var r = document.selection.createRange().text;
 if(tag == "URL"){
  val = prompt("请输入连接地址:(留空为选定地址)", "http://");
 if(val !=  "http://" && val != ""){
  val = "=" + val;
 }else{
  val = "";
 }
 }
 if(tag == "MAIL"){
  val = prompt("请输入邮箱地址:(留空为选定地址)", "");
 if(val != ""){
  val = "=" + val;
 }
 }
 rr = "[" + tag + val + "]" + r + "[/" + tag +"]";
 if(r){
  document.selection.createRange().text = rr;
 }else{
  document.all.content.value += rr;
 }
}
</script>
<form name="form1" method="post" action="">
  <input type="button" name="Submit" value="B" onClick="ubbaction('B')">
  <input type="button" name="Submit" value="I" onClick="ubbaction('I')">
  <input type="button" name="Submit" value="U" onClick="ubbaction('U')">
  <select name='ffont' onChange="ubbaction('FONT', this.options[this.selectedIndex].value); this.value = 0;">
    <option value='0'>FONT</option>
    <option value='Arial' style='font-family:Arial'>Arial</option>
    <option value='Times' style='font-family:Times'>Times</option>
    <option value='Courier' style='font-family:Courier'>Courier</option>
    <option value='Impact' style='font-family:Impact'>Impact</option>
    <option value='Geneva' style='font-family:Geneva'>Geneva</option>
    <option value='Optima' style='font-family:Optima'>Optima</option>
  </select>
  <select name='fsize' onChange="ubbaction('SIZE', this.options[this.selectedIndex].value); this.value = 0;">
    <option value='0'>SIZE</option>
    <option value='1'>Small</option>
    <option value='7'>Large</option>
    <option value='14'>Largest</option>
  </select>
  <select name='fcolor' onChange="ubbaction('COLOR', this.options[this.selectedIndex].value); this.value = 0;">
    <option value='0'>COLOR</option>
    <option value=black style="background-color:black;color:black">Black</option>
    <option value=red style="background-color:red;color:red">Red</option>
    <option value=yellow style="background-color:yellow;color:yellow">Yellow</option>
    <option value=pink style="background-color:pink;color:pink">Pink</option> 《UBB编辑器原来就这么简单》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/JavaScript/13410.html


关键字:

关于《UBB编辑器原来就这么简单》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td