• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Asp.net中FreeTextBoxJS方法代码

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
_____________________
FreeTextBox-MainScript.js
_____________________

//** FreeTextBox Main Script ********************/
//   by John Dyer
//   http://www.freetextbox.com/
//***********************************************/

/** START:BROWSER DETECTION ********************/
_d=document;
_nv=navigator.appVersion.toLowerCase();
_f=false;_t=true;
ie4=(!_d.getElementById&&_d.all)?_t:_f;
ie5=(_nv.indexOf("msie 5.0")!=-1)?_t:_f;
ie55=(_nv.indexOf("msie 5.5")!=-1)?_t:_f;
ie6=(_nv.indexOf("msie 6.0")!=-1)?_t:_f;
isIE=(ie5||ie55||ie6)?_t:_f;
/** END:BROWSER DETECTION ********************/

/** START:MAIN FREETEXTBOX FUNCTIONS ********************/
function FTB_InitializeAll() {
 for (var i=0; i<FTB_StartUpArray.length; i++)
 FTB_Initialize(FTB_StartUpArray[i]);
}

function FTB_Initialize(ftbName) {
 
 startMode = eval(ftbName + "_StartMode");
 readOnly = eval(ftbName + "_ReadOnly");
 designModeCss = eval(ftbName + "_DesignModeCss");
 htmlModeCss = eval(ftbName + "_HtmlModeCss");

 hiddenHtml = FTB_GetHiddenField(ftbName);
 editor = FTB_GetIFrame(ftbName);
 
 if (readOnly) {
  editor.document.designMode = 'Off';
 } else {
  editor.document.designMode = 'On';
 }
 
 editor.document.open();
 //if (!isIE) editor.document.write("<html><body><style type='text/css'>body { direction: rtl; }</style>");
 editor.document.write(hiddenHtml.value);
 //if (!isIE) editor.document.write("</body><html>");
 editor.document.close();
  
 if (isIE) {
  if (htmlModeCss != "" || designModeCss != "" ) {
   editor.document.createStyleSheet(designModeCss);
   editor.document.createStyleSheet(htmlModeCss);
   editor.document.styleSheets[1].disabled = true;
  }
 } else {
  // turn off <span style="font-weight:bold">, use <b>
  editor.document.execCommand("useCSS", false, true);
 }
 
 if (readOnly) {
  editor.document.contentEditable = 'False';
 } else {
  editor.document.contentEditable = 'True';
 }
 
 editor.document.body.style.border = '0';
 if (FTB_GetTextDirection(ftbName) == "RightToLeft")
  editor.document.body.style.direction = 'rtl';
 
 if (isIE) {
  editor.document.onkeydown = function() {
   return FTB_Event(ftbName); 
  };
  editor.document.onkeypress = function() {
   return FTB_Event(ftbName); 
  }; 
  editor.document.onclick = function() {
   return FTB_Event(ftbName); 
  }; 
  editor.document.onmousedown = function() {
   return FTB_Event(ftbName); 
  };  
 } else {
  editor.addEventListener("keydown", function() {
   return FTB_Event(ftbName); 
  }, true); 
  editor.addEventListener("keypress", function() {
   return FTB_Event(ftbName); 
  }, true);
  editor.addEventListener("click", function() {
   return FTB_Event(ftbName); 
  }, true);   
  editor.addEventListener("mousedown", function() {
   return FTB_Event(ftbName); 
  }, true);  
 }
 
 
 if (startMode != "DesignMode" && FTB_HideToolbar(ftbName)) {
  toolbar = FTB_GetToolbar(ftbName);
  if (toolbar != null) toolbar.style.display = 'none';
 }
 
 eval(ftbName + "_Initialized = true;");
}

function FTB_GetFtbName(ftb) {
 ftbName = ftb.name;
 underscore = ftbName.lastIndexOf("_");
 return ftbName.substring(0,underscore);
}

function FTB_ChangeMode(ftb,goToHtmlMode) {
 editor = ftb;
  
 ftbName = FTB_GetFtbName(ftb);
 var toolbar = FTB_GetToolbar(ftbName);
 var hideToolbar = FTB_HideToolbar(ftbName);
 var editorContent;
 var iframe = document.getElementById(ftbName + "_Editor");
 
 editor.focus();
 
 if (goToHtmlMode) {
  if (isIE) {   
   if (editor.document.styleSheets.length > 0) {
    editor.document.styleSheets[0].disabled = true;
    editor.document.styleSheets[1].disabled = false;    
   }
   if (FTB_HtmlModeDefaultsToMonoSpaceFont(ftbName) && editor.document.styleSheets.length < 2) {      
    editor.document.body.style.fontFamily = 'Courier New, Courier New';
    editor.document.body.style.fontSize = '10pt';    
   }
      
   editorContent = editor.document.body.innerHTML;   
   //alert(editorContent);
   editor.document.body.innerText = editorContent;
  
  } else {   

   editorContent = document.createTextNode(editor.document.body.innerHTML);
   editor.document.body.innerHTML = "";
   editor.document.body.appendChild(editorContent); 
   
  }
  
  if (toolbar != null && hideToolbar ) {
   if (!isIE) iframe.style.height = '50%';
   toolbar.style.display = 'none';
   if (!isIE) setTimeout(function() { iframe.style.height = '100%'; }, 0);    
  }  
  return true;
 } else {
  // go to Design Mode
  if (isIE) {
   editorContent = editor.document.body.innerText;
   
   if (FTB_HtmlModeDefaultsToMonoSpaceFont(ftbName) && editor.document.styleSheets.length < 2) {     
    editor.document.body.style.fontFamily = '';
    editor.document.body.style.fontSize = '';
   }     
   if (editor.document.styleSheets.length > 0) {
    editor.document.styleSheets[0].disabled = false;
    editor.document.styleSheets[1].disabled = true;
   }
   
   editor.document.body.innerHTML = editorContent;
  } else {
      
   editorContent = editor.document.body.ownerDocument.createRange();
   editorContent.selectNodeContents(editor.document.body);
   editor.document.body.innerHTML = editorContent.toString();
  }

  if (toolbar != null && hideToolbar ) {
   if (!isIE) iframe.style.height = '50%';
   toolbar.style.display = '';
   if (!isIE) setTimeout(function() { iframe.style.height = '100%'; editor.focus();}, 0);    
  }
  
  editor.focus();
  return true;
 }
}

function FTB_CopyHtmlToHidden(ftbName) {
 
 if (!FTB_Initialized(ftbName)) return;
 

 hiddenHtml = FTB_GetHiddenField(ftbName);
 editor = FTB_GetIFrame(ftbName);
 
 if (isIE) {
  if (FTB_IsHtmlMode(ftbName)) {
   hiddenHtml.value = editor.document.body.innerText; 
  } else {
   hiddenHtml.value = editor.document.body.innerHTML; 
  }  
 } else {
  if (FTB_IsHtmlMode(ftbName)) {
   editorContent = editor.document.body.ownerDocument.createRange();
   editorContent.selectNodeContents(editor.document.body);
   hiddenHtml.value = editorContent.toString();
  } else {
   hiddenHtml.value = editor.document.body.innerHTML; 
  } 
 }
 if (hiddenHtml.value == '<P>&nbsp;</P>' || hiddenHtml.value == '<br>') {
  hiddenHtml.value = '';
 }
}

function FTB_Format(ftbName,commandName) {
 editor = FTB_GetIFrame(ftbName);

 if (FTB_IsHtmlMode(ftbName)) return;
 editor.focus();
 editor.document.execCommand(commandName,'',null);
 
 //FTB_Event(ftbName);
}

function FTB_SurroundText(ftbName,start,end) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
 
 if (isIE) {
  var sel = editor.document.selection.createRange();
  html = start + sel.htmlText + end;
  sel.pasteHTML(html);  
 } else {
        selection = editor.window.getSelection();
        editor.focus();
        if (selection) {
            range = selection.getRangeAt(0);
        } else {
            range = editor.document.createRange();
        }
       
        FTB_InsertText(ftbName, start + selection + end);
 } 

}

function FTB_InsertText(ftbName,insertion) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
 if (isIE) {
  sel = editor.document.selection.createRange();
  sel.pasteHTML(insertion);
 } else {
        editor.focus();
        selection = editor.window.getSelection();
  if (selection) {
   range = selection.getRangeAt(0);
  } else {
   range = editor.document.createRange();
  }

        var fragment = editor.document.createDocumentFragment();
        var div = editor.document.createElement("div");
        div.innerHTML = insertion;

        while (div.firstChild) {
            fragment.appendChild(div.firstChild);
        }

        selection.removeAllRanges();
        range.deleteContents();

        var node = range.startContainer;
        var pos = range.startOffset;

        switch (node.nodeType) {
            case 3:
                if (fragment.nodeType == 3) {
                    node.insertData(pos, fragment.data);
                    range.setEnd(node, pos + fragment.length);
                    range.setStart(node, pos + fragment.length);
                } else {
                    node = node.splitText(pos);
                    node.parentNode.insertBefore(fragment, node);
                    range.setEnd(node, pos + fragment.length);
                    range.setStart(node, pos + fragment.length);
                }
                break;

            case 1:
                node = node.childNodes[pos];
                node.parentNode.insertBefore(fragment, node);
                range.setEnd(node, pos + fragment.length);
                range.setStart(node, pos + fragment.length);
                break;
        }
        selection.addRange(range); 
 }
}
function FTB_CheckTag(item,tagName) {
 if (item.tagName.search(tagName)!=-1) {
  return item;
 }
 if (item.tagName=='BODY') {
  return false;
 }
 item=item.parentElement;
 return FTB_CheckTag(item,tagName);
}
/** END:MAIN FREETEXTBOX FUNCTIONS ********************/

/** START:PROPERTIES ********************/
function FTB_IsHtmlMode(ftbName) {
 return (eval(ftbName + "_HtmlMode"));
}

function FTB_TabMode(ftbName) {
 return (eval(ftbName + "_TabMode"));
}

function FTB_BreakMode(ftbName) {
 return (eval(ftbName + "_BreakMode"));
}

function FTB_HtmlModeDefaultsToMonoSpaceFont(ftbName) {
 return (eval(ftbName + "_HtmlModeDefaultsToMonoSpaceFont"));
}

function FTB_HideToolbar(ftbName) {
 return (eval(ftbName + "_HideToolbar"));
}

function FTB_UpdateToolbar(ftbName) {
 return (eval(ftbName + "_UpdateToolbar"));
}

function FTB_ButtonRenderMode(ftbName) {
 return (eval(ftbName + "_ButtonRenderMode"));
}

function FTB_GetHiddenField(ftbName) {
 return document.getElementById(ftbName);
}

function FTB_GetTextDirection(ftbName) {
 return (eval(ftbName + "_TextDirection"));
}

function FTB_Initialized(ftbName) {
 return (eval(ftbName + "_Initialized"));
}

function FTB_GetIFrame(ftbName) {
 if (isIE) {
  return eval(ftbName + "_Editor");
  //return document.getElementById(ftbName + "_Editor");
 } else {
  return document.getElementById(ftbName + "_Editor").contentWindow;
 }
}

function FTB_GetToolbar(ftbName) {
 return document.getElementById(ftbName + "_Toolbar");
}
function FTB_GetToolbarArray(ftbName) {
 return eval(ftbName + "_ToolbarItems");
}
function FTB_GetCssID(ftbName) {
 cssID = ftbName;
 while (cssID.substring(0,1) == '_') {
  cssID = cssID.substring(1);
 }
 return cssID;
}

/** START: BUTTONS **************/

/** CSS BUTTON FUNCTIONS **************/
function FTB_SetButtonStyle(buttonTD,style,checkstyle) {
 if (buttonTD == null) return;
 if (buttonTD.className != checkstyle)
  buttonTD.className = style;
 
}
function FTB_GetClassSubName(className) {
 underscore = className.indexOf("_");
 if (underscore < 0) return className;
 return className.substring(underscore+1);
}

/** JS BUTTON FUNCTIONS **************/
function FTB_ButtonOver(theTD,ftbName,imageOver,imageDown) {
 FTB_SetButtonStyle(theTD,FTB_GetCssID(ftbName)+'_ButtonOver',null);
 
 //if (eval(ftbName+'_OverImage').src != '')
 // theTD.style.backgroundImage = "url(" + eval(ftbName+'_OverImage').src + ")";
 
 if(imageOver == 1 & theTD.childNodes.length && theTD.childNodes[0].tagName == "IMG"){
  oldSrc = theTD.childNodes[0].src;
  if (oldSrc.indexOf('.over.') == -1) {
   theTD.childNodes[0].src=oldSrc.substring(0, oldSrc.length-4) + ".over.gif";
  }
 }
 
 //FTB_Event(ftbName);
}
function FTB_ButtonOut(theTD,ftbName,imageOver,imageDown) {
 FTB_SetButtonStyle(theTD,FTB_GetCssID(ftbName)+'_ButtonNormal',null);
 document.body.style.cursor = 'default';
 
 theTD.style.backgroundImage='';
 
 if(theTD.childNodes.length && theTD.childNodes[0].tagName == "IMG"){
  oldSrc = theTD.childNodes[0].src;
  if (oldSrc.indexOf('.over.') > 0) {
   theTD.childNodes[0].src=oldSrc.substring(0, oldSrc.length-9) + ".gif";
  }
  if (oldSrc.indexOf('.down.') > 0) {
   theTD.childNodes[0].src=oldSrc.substring(0, oldSrc.length-9) + ".gif";
  }
 }
 
 //FTB_Event(ftbName);
}
function FTB_ButtonDown(theTD,ftbName,imageOver,imageDown) {
 document.body.style.cursor = 'default';
 FTB_SetButtonStyle(theTD,FTB_GetCssID(ftbName)+'_ButtonDown',null);

 //if (eval(ftbName+'_DownImage').src != '')
 // theTD.style.backgroundImage = "url(" + eval(ftbName+'_DownImage').src + ")";
 
 if(imageDown == 1 && theTD.children.length && theTD.children[0].tagName == "IMG"){
  oldSrc = theTD.children[0].src;
  if (oldSrc.indexOf('.over.') > 0) {
   theTD.children[0].src=oldSrc.substring(0, oldSrc.length-9) + ".down.gif";
  }
 }
 
 //FTB_Event(ftbName);
}
function FTB_ButtonUp(theTD,ftbName,imageOver,imageDown) {
 document.body.style.cursor = 'auto';
 FTB_SetButtonStyle(theTD,FTB_GetCssID(ftbName)+'_ButtonOver',null);

 //if (eval(ftbName+'_OverImage').src != '')
 // theTD.style.backgroundImage = "url(" + eval(ftbName+'_OverImage').src + ")";
 
 if(imageOver == 1 && theTD.children.length && theTD.children[0].tagName == "IMG"){
  oldSrc = theTD.children[0].src;
  if (oldSrc.indexOf('.over.') == -1) {
   theTD.children[0].src=oldSrc.substring(0, oldSrc.length-4) + ".over.gif";
  }
 }
 
 //FTB_Event(ftbName);
}

/** END:PROPERTIES ********************/

/** START:TABS ********************/
function FTB_SetActiveTab(theTD,ftbName) {
 parentTR = theTD.parentElement;
 parentTR = document.getElementById(ftbName + "_TabRow");

 selectedTab = 1;
 totalButtons = parentTR.cells.length-1;
 for (var i=1;i< totalButtons;i++) {
  parentTR.cells[i].className = FTB_GetCssID(ftbName) + "_TabOffRight";
  if (theTD == parentTR.cells[i]) { selectedTab = i; }
 }

 if (selectedTab==1) {
  parentTR.cells[0].className = FTB_GetCssID(ftbName) + "_StartTabOn";
 } else {
  parentTR.cells[0].className = FTB_GetCssID(ftbName) + "_StartTabOff";
  parentTR.cells[selectedTab-1].className = FTB_GetCssID(ftbName) + "_TabOffLeft";
 }

 theTD.className = FTB_GetCssID(ftbName) + "_TabOn";
}
function FTB_TabOver() {
 document.body.style.cursor='default';
}
function FTB_TabOut() {
 document.body.style.cursor='auto';
}
/** END:TABS ********************/

function FTB_Event(ftbName) {
 
 editor = FTB_GetIFrame(ftbName);
 htmlMode = FTB_IsHtmlMode(ftbName);
 var _TAB = 9;
 var _ENTER = 13;
 var _QUOTE = 222;
 var _OPENCURLY = '“';
 var _CLOSECURLY = '”';
 
 if (isIE) {
 // TAB Functions
  if (editor.event.keyCode == _TAB) { 

   var tabMode = FTB_TabMode(ftbName);

   if (tabMode == "Disabled") {
    editor.event.cancelBubble = true;
    editor.event.returnValue = false;
   }
   if (tabMode == "InsertSpaces") {
    FTB_InsertText(ftbName,"&nbsp;&nbsp;&nbsp;");
    editor.event.cancelBubble = true;
    editor.event.returnValue = false;
   }   
   if (tabMode == "NextControl") {
    // do nothing for TabMode.NextControl
   } 
  }

  // IE defaults to <p>, Mozilla to <br>
  if (editor.event.keyCode == _ENTER) {


   var breakMode = FTB_BreakMode(ftbName);   

   if (breakMode == "LineBreak" || editor.event.ctrlKey || htmlMode) {
    var sel = editor.document.selection;
    if (sel.type == 'Control') {
     return;
    }
    var r = sel.createRange();
    if ((!FTB_CheckTag(r.parentElement(),'LI'))&&(!FTB_CheckTag(r.parentElement(),'H'))) {
     r.pasteHTML('<br>');
     editor.event.cancelBubble = true;
     editor.event.returnValue = false;
     r.select();
     r.collapse(false);
     return false;
    }     
   }
  }
 }
 
 // update ToolbarItems only every 50 milliseconds b/c it is expensive
 if (!htmlMode && FTB_UpdateToolbar(ftbName)) {  
  if (editor.timerToolbar) {
   clearTimeout(editor.timerToolbar);
  }
  editor.timerToolbar = setTimeout(function() {
   FTB_SetToolbarItems(ftbName);
   editor.timerToolbar = null;
  }, 50); 
 }
}

function FTB_SetToolbarItems(ftbName) {
 editor = FTB_GetIFrame(ftbName);
 htmlMode = FTB_IsHtmlMode(ftbName);
 toolbarArray =  FTB_GetToolbarArray(ftbName);
  
 //document.getElementById("Debug").value = "";
 
 if (toolbarArray) {
  for (var i=0; i<toolbarArray.length; i++) {
   toolbarItemID = toolbarArray[i][0];
   toolbarItem = document.getElementById(toolbarItemID);
   commandIdentifier = toolbarArray[i][1];

   state = "";
   try {
    if (toolbarItemID.indexOf("Button") > -1) {
     state = editor.document.queryCommandState(commandIdentifier);

     FTB_SetButtonState(toolbarItemID,ftbName,state);
    } else {
     state = editor.document.queryCommandValue(commandIdentifier);
     
     switch (commandIdentifier) {
      case "backcolor":
       if (isIE) {
        state = FTB_GetHexColor(state);
       } else {
        if (state == "") state = "#FFFFFF";
       }
       break;      
      case "forecolor":
       if (isIE) {
        state = FTB_GetHexColor(state);
       } else {
        if (state == "") state = "#000000";
       }
       break;
      case "formatBlock":
       //document.getElementById("Debug").value += "****: " + state + "\n";
       if (!isIE) {
        if (state == "p" || state == "" || state == "<x>")
         state = "<body>";
        else
         state = "<" + state + ">";       
       }
       break;     
     }
      
     //document.getElementById("Debug").value += commandIdentifier + ": " + state + "\n";
     
     FTB_SetDropDownListState(toolbarItemID,state);     
    }
   } catch(e) {
   }
  }
 }
}

function FTB_GetHexColor(intColor) {
 intColor = intColor.toString(16).toUpperCase();
 while (intColor.length < 6) {
  intColor = "0" + intColor;
 }
 return "#" + intColor.substring(4,6) + intColor.substring(2,4) + intColor.substring(0,2);
}

function FTB_SetDropDownListState(ddlName,value) {
 ddl = document.getElementById(ddlName);
 
 if (ddl) {
  for (var i=0; i<ddl.options.length; i++) {
   if (ddl.options[i].text == value || ddl.options[i].value == value) {
    ddl.options.selectedIndex = i;
    return;
   } 
  }
 }
}

function FTB_SetButtonState(buttonName,ftbName,value) {
 buttonTD = document.getElementById(buttonName);
 
 if (buttonTD) {
  if (value) {
   if (FTB_ButtonRenderMode(ftbName) == 'Css')
    buttonTD.className = FTB_GetCssID(ftbName) + "_ButtonActive";
   else
    FTB_ButtonOver(buttonTD,ftbName,0,0);
  } else {
   if (FTB_ButtonRenderMode(ftbName) == 'Css')
    buttonTD.className = FTB_GetCssID(ftbName) + "_ButtonNormal";
   else
    FTB_ButtonOut(buttonTD,ftbName,0,0);
  }
 }
}

// *******************************

function FTB_GetParentElement(ftbName) {
 editor = FTB_GetIFrame(ftbName);

 var sel = FTB_GetSelection(ftbName);
 var range = FTB_CreateRange(ftbName,sel);
 if (isIE) {
  switch (sel.type) {
      case "Text":
      case "None":
    // It seems that even for selection of type "None",
    // there _is_ a parent element and it's value is not
    // only correct, but very important to us.  MSIE is
    // certainly the buggiest browser in the world and I
    // wonder, God, how can Earth stand it?
    return range.parentElement();
      case "Control":
    return range.item(0);
      default:
    return editor.document.body;
  }
 } else try {
  var p = range.commonAncestorContainer;
  if (!range.collapsed && range.startContainer == range.endContainer &&
      range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes())
   p = range.startContainer.childNodes[range.startOffset];
  /*
  alert(range.startContainer + ":" + range.startOffset + "\n" +
        range.endContainer + ":" + range.endOffset);
  */
  while (p.nodeType == 3) {
   p = p.parentNode;
  }
  return p;
 } catch (e) {
  return null;
 }
}

function FTB_InsertNodeAtSelection(ftbName,toBeInserted) {
 if (!isIE) {
  var editor = FTB_GetIFrame(ftbName);
  var sel = FTB_GetSelection(ftbName);
  var range = FTB_CreateRange(ftbName,sel);
  // remove the current selection
  sel.removeAllRanges();
  range.deleteContents();
  var node = range.startContainer;
  var pos = range.startOffset;
  switch (node.nodeType) {
      case 3: // Node.TEXT_NODE
   // we have to split it at the caret position.
   if (toBeInserted.nodeType == 3) {
    // do optimized insertion
    node.insertData(pos, toBeInserted.data);
    range = this._createRange();
    range.setEnd(node, pos + toBeInserted.length);
    range.setStart(node, pos + toBeInserted.length);
    sel.addRange(range);
   } else {
    node = node.splitText(pos);
    var selnode = toBeInserted;
    if (toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */) {
     selnode = selnode.firstChild;
    }
    node.parentNode.insertBefore(toBeInserted, node);
    editor.selectNodeContents(selnode);
   }
   break;
      case 1: // Node.ELEMENT_NODE
   var selnode = toBeInserted;
   if (toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */) {
    selnode = selnode.firstChild;
   }
   node.insertBefore(toBeInserted, node.childNodes[pos]);
   FTB_SelectNodeContents(editor,selnode);
   break;
  }
 }
}

// Selects the contents inside the given node
function FTB_SelectNodeContents(ftbName, node, pos) {
 

 editor = FTB_GetIFrame(ftbName);
 

 var range;
 var collapsed = (typeof pos != "undefined");
 if (isIE) {
  range = editor.document.body.createTextRange();
  range.moveToElementText(node);
  (collapsed) && range.collapse(pos);
  range.select();
 } else {
  var sel = FTB_GetSelection(ftbName);
  range = editor.document.createRange();
  range.selectNodeContents(node);
  (collapsed) && range.collapse(pos);
  sel.removeAllRanges();
  sel.addRange(range);
 }
};

// returns the current selection object
function FTB_GetSelection(ftbName) {
 editor = FTB_GetIFrame(ftbName);
 if (isIE) {
  return editor.document.selection;
 } else {
  return editor.getSelection();
 }
}

// returns a range for the current selection
function FTB_CreateRange(ftbName,sel) {
 editor = FTB_GetIFrame(ftbName);
 if (isIE) {
  return sel.createRange();
 } else {
  //TODO: this.focusEditor();
  if (typeof sel != "undefined") {
   try {
    return sel.getRangeAt(0);
   } catch(e) {
    return editor.document.createRange();
   }
  } else {
   return editor.document.createRange();
  }
 }
}

/* TABLE FUNCTIONS
   MODIFIED FROM HtmlArea (thanks guys!)
**********************************************/

// helper function that clears the content in a table row
function FTB_ClearRow(tr) {
 var tds = tr.getElementsByTagName("td");
 for (var i = tds.length; --i >= 0;) {
  var td = tds[i];
  td.rowSpan = 1;
  td.innerHTML = (isIE) ? "" : "<br />";
 }
}

function FTB_SplitRow(td) {
 var n = parseInt("" + td.rowSpan);
 var nc = parseInt("" + td.colSpan);
 td.rowSpan = 1;
 tr = td.parentNode;
 var itr = tr.rowIndex;
 var trs = tr.parentNode.rows;
 var index = td.cellIndex;
 while (--n > 0) {
  tr = trs[++itr];
  var otd = editor._doc.createElement("td");
  otd.colSpan = td.colSpan;
  otd.innerHTML = mozbr;
  tr.insertBefore(otd, tr.cells[index]);
 }
 //editor.forceRedraw();
 //editor.updateToolbar();
}

function FTB_SplitCol(td) {
 var nc = parseInt("" + td.colSpan);
 td.colSpan = 1;
 tr = td.parentNode;
 var ref = td.nextSibling;
 while (--nc > 0) {
  var otd = editor._doc.createElement("td");
  otd.rowSpan = td.rowSpan;
  otd.innerHTML = mozbr;
  tr.insertBefore(otd, ref);
 }
 //editor.forceRedraw();
 //editor.updateToolbar();
}

function FTB_SplitCell(td) {
 var nc = parseInt("" + td.colSpan);
 splitCol(td);
 var items = td.parentNode.cells;
 var index = td.cellIndex;
 while (nc-- > 0) {
  FTB_SplitRow(items[index++]);
 }
}

function FTB_SelectNextNode(el) {
 var node = el.nextSibling;
 while (node && node.nodeType != 1) {
  node = node.nextSibling;
 }
 if (!node) {
  node = el.previousSibling;
  while (node && node.nodeType != 1) {
   node = node.previousSibling;
  }
 }
 if (!node) {
  node = el.parentNode;
 }
 //editor.selectNodeContents(node);
}

function FTB_GetClosest(ftbName,tagName) {
 var editor = FTB_GetIFrame(ftbName);
 var ancestors = FTB_GetAllAncestors(ftbName);
 var ret = null;
 tagName = ("" + tagName).toLowerCase();
 for (var i in ancestors) {
  var el = ancestors[i];
  if (el.tagName.toLowerCase() == tagName) {
   ret = el;
   break;
  }
 }
 return ret;
}
function FTB_GetAllAncestors(ftbName) {
 editor = FTB_GetIFrame(ftbName);
 var p = FTB_GetParentElement(ftbName);
 var a = [];
 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
  a.push(p);
  p = p.parentNode;
 }
 a.push(editor.document.body);
 return a;
}
function FTB_InsertColumn(ftbName,after) {
   editor = FTB_GetIFrame(ftbName);
   var td = FTB_GetClosest(ftbName,"td");
   if (!td) {
      return;
   }
   var rows = td.parentNode.parentNode.rows;
   var index = td.cellIndex;
   for (var i = rows.length; --i >= 0;) {
      var tr = rows[i];
      var otd = editor.document.createElement("td");
      otd.innerHTML = (isIE) ? "" : "<br />";

      //if last column and insert column after is select append child
      if (index==tr.cells.length-1 && after) {
         tr.appendChild(otd);
      } else {
         var ref = tr.cells[index + ((after) ? 1 : 0)]; // 0
         tr.insertBefore(otd, ref);
      }
   }
}
function FTB_InsertTableRow(ftbName,after) {
 if (FTB_IsHtmlMode(ftbName)) return; 
 var tr = FTB_GetClosest(ftbName,"tr");
 if (!tr) {
  return;
 }
 var otr = tr.cloneNode(true);
 FTB_ClearRow(otr);
 tr.parentNode.insertBefore(otr, ((after) ? tr.nextSibling : tr));
}
function FTB_CreateTable(ftbName,cols,rows,width,widthUnit,align,cellpadding,cellspacing,border) {
 var editor = FTB_GetIFrame(ftbName);
 var sel = FTB_GetSelection(ftbName);
 var range = FTB_CreateRange(ftbName,sel); 
 
 var doc = editor.document;
 // create the table element
 var table = doc.createElement("table");
 

 // assign the given arguments
 table.style.width  = width + widthUnit;
 table.align    = align;
 table.border   = border;
 table.cellspacing  = cellspacing;
 table.cellpadding  = cellpadding;

 
 var tbody = doc.createElement("tbody");
 table.appendChild(tbody); 

 for (var i = 0; i < rows; ++i) {
  var tr = doc.createElement("tr");
  tbody.appendChild(tr);
  for (var j = 0; j < cols; ++j) {
   var td = doc.createElement("td");
   tr.appendChild(td);
   // Mozilla likes to see something inside the cell.
   if (!isIE) td.appendChild(doc.createElement("br"));
  }
 }
 
 if (isIE) {
  range.pasteHTML(table.outerHTML);
 } else {
  FTB_InsertNodeAtSelection(ftbName,table);
 }
 
 return true;
}
-----------------------------------------------------------------------
____________________
FreeTextBox-ToolbarItemsScript.js
__________________________

//** FreeTextBox Builtin ToolbarItems Script (2.0.7) ***/
//   by John Dyer
//   http://www.freetextbox.com/
//**********************************************/

function FTB_Bold(ftbName) {
 FTB_Format(ftbName,'bold');
}
function FTB_BulletedList(ftbName) {
 FTB_Format(ftbName,'insertunorderedlist');
}
function FTB_Copy(ftbName) {
 try {
  FTB_Format(ftbName,'copy');
 } catch (e) {
  alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
 }

}
function FTB_CreateLink(ftbName) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
 if (isIE) {
  editor.document.execCommand('createlink','1',null);
 } else {
  var url = prompt('Enter a URL:', 'http://');
  if ((url != null) && (url != ''))  editor.document.execCommand('createlink',false,url);
 }
}
function FTB_Cut(ftbName) {
 try {
  FTB_Format(ftbName,'cut');
 } catch (e) {
  alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
 }

}
function FTB_Delete(ftbName) {
 editor = FTB_GetIFrame(ftbName);
 if (confirm('Do you want to delete all the HTML and text presently in the editor?')) { 
  editor.document.body.innerHTML = '';
  if (isIE) {   
   editor.document.body.innerText = '';
  }
 }
 editor.focus();
}
function FTB_DeleteTableColumn(ftbName) {
 if (FTB_IsHtmlMode(ftbName)) return;
 var td = this.FTB_GetClosest(ftbName,"td");
 if (!td) {
  return;
 }
 var index = td.cellIndex;
 if (td.parentNode.cells.length == 1) {
  //alert("Don't delete last column");
  return;
 }
 // set the caret first to a position that doesn't disappear
 FTB_SelectNextNode(td);
 var rows = td.parentNode.parentNode.rows;
 for (var i = rows.length; --i >= 0;) {
  var tr = rows[i];
  tr.removeChild(tr.cells[index]);
 }
}
function FTB_DeleteTableRow(ftbName) {
 var tr = FTB_GetClosest(ftbName,"tr");
 if (!tr) {
  return;
 }
 var par = tr.parentNode;
 if (par.rows.length == 1) {
  //alert("Don't delete the last row!");
  return;
 }
 // set the caret first to a position that doesn't
 // disappear.
 FTB_SelectNextNode(tr);
 par.removeChild(tr);
}
function FTB_ieSpellCheck(ftbName) {
    if (FTB_IsHtmlMode(ftbName)) return;
 if (!isIE) {
  alert('IE Spell is not supported in Mozilla');
  return;
 }
 try {
  var tspell = new ActiveXObject('ieSpell.ieSpellExtension');
  tspell.CheckAllLinkedDocuments(window.document);
 } catch (err){
  if (window.confirm('You need ieSpell to use spell check. Would you like to install it?')){window.open('http://www.iespell.com/download.php');};
 };

}
function FTB_Indent(ftbName) {
 FTB_Format(ftbName,'indent');
}
function FTB_InsertDate(ftbName) {
 var d = new Date();
 FTB_InsertText(ftbName,d.toLocaleDateString());
}
function FTB_InsertImage(ftbName) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
    editor.document.execCommand('insertimage',1,'');
}
function FTB_InsertRule(ftbName) {
 FTB_Format(ftbName,'inserthorizontalrule');
}
function FTB_InsertTable(ftbName) {
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
 
 var tableWin = window.open("","tableWin","width=400,height=180");
 tableWin.focus();
 
 tableWin.document.body.innerHTML = "";
 tableWin.document.write("<html>\
<head> \
<style type='text/css'> \
html, body { \
  background: ButtonFace; \
  color: ButtonText; \
  font: 11px Tahoma,Verdana,sans-serif; \
  margin: 0px; \
  padding: 0px; \
} \
body { padding: 5px; } \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
button { width: 70px; } \
.space { padding: 2px; } \
 \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
form { padding: 0px; margin: 0px; } \
</style> \
<script language='JavaScript'> \
function insertTable() { \
 cols = parseInt(document.getElementById('f_cols').value); \
 rows = parseInt(document.getElementById('f_rows').value); \
 width = document.getElementById('f_width').value; \
 widthUnit = document.getElementById('f_unit').options[document.getElementById('f_unit').selectedIndex].value; \
 align = document.getElementById('f_align').value; \
 cellpadding = document.getElementById('f_padding').value; \
 cellspacing = document.getElementById('f_spacing').value; \
 border = document.getElementById('f_border').value; \
 window.opener.FTB_CreateTable('" + ftbName + "',cols,rows,width,widthUnit,align,cellpadding,cellspacing,border); \
} \
</script> \
</head> \
<body> \
<form action=''> \
 \
<table border='0' style='padding: 0px; margin: 0px'> \
  <tbody> \
  <tr> \
    <td style='width: 4em; text-align: right'>Rows:</td> \
    <td><input type='text' name='rows' id='f_rows' size='5' title='Number of rows' value='2' /></td> \
    <td></td> \
    <td></td> \
    <td></td> \
  </tr> \
  <tr> \
    <td style='width: 4em; text-align: right'>Cols:</td> \
    <td><input type='text' name='cols' id='f_cols' size='5' title='Number of columns' value='4' /></td> \
    <td style='width: 4em; text-align: right'>Width:</td> \
    <td><input type='text' name='width' id='f_width' size='5' title='Width of the table' value='100' /></td> \
    <td><select size='1' name='unit' id='f_unit' title='Width unit'> \
      <option value='%' selected='1'  >Percent</option> \
      <option value='px'              >Pixels</option> \
      <option value='em'              >Em</option> \
    </select></td> \
  </tr> \
  </tbody> \
</table> \
 \
<fieldset style='float: left; margin-left: 5px;'> \
<legend>Layout</legend> \
 \
<div class='space'></div> \
 \
<div class='fl'>Alignment:</div> \
<select size='1' name='align' id='f_align' \
  title='Positioning of this image'> \
  <option value='' selected='1'                >Not set</option> \
  <option value='left'                         >Left</option> \
  <option value='right'                        >Right</option> \
  <option value='texttop'                      >Texttop</option> \
  <option value='absmiddle'                    >Absmiddle</option> \
  <option value='baseline'                     >Baseline</option> \
  <option value='absbottom'                    >Absbottom</option> \
  <option value='bottom'                       >Bottom</option> \
  <option value='middle'                       >Middle</option> \
  <option value='top'                          >Top</option> \
</select> \
 \
<p /> \
 \
<div class='fl'>Border thickness:</div> \
<input type='text' name='border' id='f_border' size='5' value='1' title='Leave empty for no border' /> \
 \
<div class='space'></div> \
 \
</fieldset> \
 \
<fieldset style='float:right; margin-right: 5px;'> \
<legend>Spacing</legend> \
 \
<div class='space'></div> \
 \
<div class='fr'>Cell spacing:</div> \
<input type='text' name='spacing' id='f_spacing' size='5' value='1' \
title='Space between adjacent cells' /> \
 \
<p /> \
 \
<div class='fr'>Cell padding:</div> \
<input type='text' name='padding' id='f_padding' size='5' value='1' \
title='Space between content and border in cell' /> \
 \
<div class='space'></div> \
 \
</fieldset> \
\
<div style='margin-top: 85px; border-top: 1px solid #999; padding: 2px; text-align: right;'> \
<button type='button' name='ok' onclick='insertTable();window.close();'>Insert</button> \
<button type='button' name='cancel' onclick='window.close();'>Cancel</button> \
</div> \
</form> \
</body></html>");
}
function FTB_InsertTableColumnAfter(ftbName) {
 FTB_InsertColumn(ftbName,true);
}
function FTB_InsertTableColumnBefore(ftbName) {
 FTB_InsertColumn(ftbName,false);
}
function FTB_InsertTableRowAfter(ftbName) {
 FTB_InsertTableRow(ftbName,true);
}
function FTB_InsertTableRowBefore(ftbName) {
 FTB_InsertTableRow(ftbName,false);
}
function FTB_InsertTime(ftbName) {
 var d = new Date();
 FTB_InsertText(ftbName,d.toLocaleTimeString());
}
function FTB_Italic(ftbName) {
 FTB_Format(ftbName,'italic');
}
function FTB_JustifyRight(ftbName) {
 FTB_Format(ftbName,'justifyright');
}
function FTB_JustifyCenter(ftbName) {
 FTB_Format(ftbName,'justifycenter');
}
function FTB_JustifyFull(ftbName) {
 FTB_Format(ftbName,'justifyfull');
}
function FTB_JustifyLeft(ftbName) {
 FTB_Format(ftbName,'justifyleft');
}
function FTB_NetSpell(ftbName) {
    if (FTB_IsHtmlMode(ftbName)) return;
 try {
  checkSpellingById(ftbName + '_Editor');
 } catch(e) {
  alert('Netspell libraries not properly linked.');
 }
}
function FTB_NumberedList(ftbName) {
 FTB_Format(ftbName,'insertorderedlist');
}
function FTB_Outdent(ftbName) {
 FTB_Format(ftbName,'outdent');
}
function FTB_Paste(ftbName) {
 try {
  FTB_Format(ftbName,'paste');
 } catch (e) {
  alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
 }
}
function FTB_Print(ftbName) {
 if (isIE) {
  FTB_Format(ftbName,'print');
 } else {
  editor = FTB_GetIFrame(ftbName);
  editor.print();
 }
}
function FTB_Redo(ftbName) {
 FTB_Format(ftbName,'undo');
}
function FTB_RemoveFormat(ftbName) {
 FTB_Format(ftbName,'removeformat');
}
function FTB_Save(ftbName) {
 FTB_CopyHtmlToHidden(ftbName);
 __doPostBack(ftbName,'Save');
}
function FTB_StrikeThrough(ftbName) {
 FTB_Format(ftbName,'strikethrough');
}
function FTB_SubScript(ftbName) {
 FTB_Format(ftbName,'subscript');
}
function FTB_SuperScript(ftbName) {
 FTB_Format(ftbName,'superscript');
}
function FTB_Underline(ftbName) {
 FTB_Format(ftbName,'underline');
}
function FTB_Undo(ftbName) {
 FTB_Format(ftbName,'undo');
}
function FTB_Unlink(ftbName) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
    editor.document.execCommand('unlink',false,null);
}
function FTB_SetFontBackColor(ftbName,name,value) {
 editor = FTB_GetIFrame(ftbName);
 
 if (FTB_IsHtmlMode(ftbName)) return;
 editor.focus();
 editor.document.execCommand('backcolor','',value);
}
function FTB_SetFontFace(ftbName,name,value) {
 editor = FTB_GetIFrame(ftbName);
 
 if (FTB_IsHtmlMode(ftbName)) return;
 editor.focus();
 editor.document.execCommand('fontname','',value);
}
function FTB_SetFontForeColor(ftbName,name,value) {
 editor = FTB_GetIFrame(ftbName);
 
 if (FTB_IsHtmlMode(ftbName)) return;
 editor.focus();
 editor.document.execCommand('forecolor','',value);
}
function FTB_SetFontSize(ftbName,name,value) {
 editor = FTB_GetIFrame(ftbName);
 
 if (FTB_IsHtmlMode(ftbName)) return;
 editor.focus();
 editor.document.execCommand('fontsize','',value);
}
function FTB_InsertHtmlMenu(ftbName,name,value) {
 FTB_InsertText(ftbName,value);
}
function FTB_SetParagraph(ftbName,name,value) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 if (value == '<body>') {
  editor.document.execCommand('formatBlock','','Normal');
  editor.document.execCommand('removeFormat');
  return;
 }
 editor.document.execCommand('formatBlock','',value);
}
function FTB_SetStyle(ftbName,name,value) {
 var className = value;
 editor = FTB_GetIFrame(ftbName);
 
 // retrieve parent element of the selection
 var parent = FTB_GetParentElement(ftbName);
 
 var surround = true;

 var isSpan = (parent && parent.tagName.toLowerCase() == "span");
 
 /*
 // remove class stuff??
 if (isSpan && index == 0 && !/\S/.test(parent.style.cssText)) {
  while (parent.firstChild) {
   parent.parentNode.insertBefore(parent.firstChild, parent);
  }
  parent.parentNode.removeChild(parent);
  editor.updateToolbar();
  return;
 }
 */
 
 // if we're already in a SPAN
 if (isSpan) {
  if (parent.childNodes.length == 1) {
   parent.className = className;
   surround = false;
   FTB_SetToolbarItems(ftbName);
  }
 }

 if (surround) {
  FTB_SurroundText(ftbName,"<span class='" + className + "'>", "</span>");
 }
}
function FTB_SymbolsMenu(ftbName,name,value) {
 FTB_InsertText(ftbName,value);
}


function FTB_InsertMSNEmoticons(ftbName) {
   if (!isIE)
   {
    alert("Not support!");
   }
   if (FTB_IsHtmlMode(ftbName)) return;
   editor = FTB_GetIFrame(ftbName);
   editor.focus();
   var folder = "Emoticons/MSN";
   var galleryscript ="EmoticonsGallery.aspx?rif="+folder+"&cif="+folder;
   imgArr = showModalDialog(galleryscript,window,"help:0;status:0;resizeable:1;");
   if (imgArr != null)
    {
     imagestring = "<IMG  ALT='" + imgArr["tip"] + "' SRC='" + imgArr["filename"] + "' HEIGHT=" + imgArr["height"] + " WIDTH=" + imgArr["width"] + " BORDER=0>";
     sel = editor.document.selection.createRange();
     sel.pasteHTML(imagestring);
     
    }
   else
    {
     return;
    }
}


function FTB_InsertQQEmoticons(ftbName) {
   if (!isIE)
   {
    alert("Not support!");
   }
   if (FTB_IsHtmlMode(ftbName)) return;
   editor = FTB_GetIFrame(ftbName);
   editor.focus();
   var folder = "Emoticons/QQ";
   var galleryscript ="EmoticonsGallery.aspx?rif="+folder+"&cif="+folder;
   imgArr = showModalDialog(galleryscript,window,"help:0;status:0;resizeable:1;");
   if (imgArr != null)
    {
     imagestring = "<IMG  ALT='" + imgArr["tip"] + "' SRC='" + imgArr["filename"] + "' HEIGHT=" + imgArr["height"] + " WIDTH=" + imgArr["width"] + " BORDER=0>";
     sel = editor.document.selection.createRange();
     sel.pasteHTML(imagestring);
     
    }
   else
    {
     return;
    }
}

function FTB_InsertTAOBAOEmoticons(ftbName) {
   if (!isIE)
   {
    alert("Not support!");
   }
   if (FTB_IsHtmlMode(ftbName)) return;
   editor = FTB_GetIFrame(ftbName);
   editor.focus();
   var folder = "Emoticons/TAOBAO";
   var galleryscript ="EmoticonsGallery.aspx?rif="+folder+"&cif="+folder;
   imgArr = showModalDialog(galleryscript,window,"help:0;status:0;resizeable:1;");
   if (imgArr != null)
    {
     imagestring = "<IMG ALT='" + imgArr["tip"] + "' SRC='" + imgArr["filename"] + "' HEIGHT=" + imgArr["height"] + " WIDTH=" + imgArr["width"] + " BORDER=0>";
     sel = editor.document.selection.createRange();
     sel.pasteHTML(imagestring);
     
    }
   else
    {
     return;
    }
}

function FTB_InsertJuPaiEmoticons(ftbName) {
   if (!isIE)
   {
    alert("Not support!");
   }
   if (FTB_IsHtmlMode(ftbName)) return;
   editor = FTB_GetIFrame(ftbName);
   editor.focus();
   var folder = "Emoticons/JuPai";
   var galleryscript ="EmoticonsGallery.aspx?rif="+folder+"&cif="+folder;
   imgArr = showModalDialog(galleryscript,window,"help:0;status:0;resizeable:1;");
   if (imgArr != null)
    {
     imagestring = "<IMG ALT='" + imgArr["tip"] + "' SRC='" + imgArr["filename"] + "' HEIGHT=" + imgArr["height"] + " WIDTH=" + imgArr["width"] + " BORDER=0>";
     sel = editor.document.selection.createRange();
     sel.pasteHTML(imagestring);
     
    }
   else
    {
     return;
    }
}


---------------------------------------------------------------
_____________________
FreeTextBox-ToolbarItemsScript1.js
_______________________________

//** FreeTextBox Builtin ToolbarItems Script (2.0.7) ***/
//   by John Dyer
//   http://www.freetextbox.com/
//**********************************************/

function FTB_Bold(ftbName) {
 FTB_Format(ftbName,'bold');
}
function FTB_BulletedList(ftbName) {
 FTB_Format(ftbName,'insertunorderedlist');
}
function FTB_Copy(ftbName) {
 try {
  FTB_Format(ftbName,'copy');
 } catch (e) {
  alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
 }

}
function FTB_CreateLink(ftbName) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
 if (isIE) {
  editor.document.execCommand('createlink','1',null);
 } else {
  var url = prompt('Enter a URL:', 'http://');
  if ((url != null) && (url != ''))  editor.document.execCommand('createlink',false,url);
 }
}
function FTB_Cut(ftbName) {
 try {
  FTB_Format(ftbName,'cut');
 } catch (e) {
  alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
 }

}
function FTB_Delete(ftbName) {
 editor = FTB_GetIFrame(ftbName);
 if (confirm('Do you want to delete all the HTML and text presently in the editor?')) { 
  editor.document.body.innerHTML = '';
  if (isIE) {   
   editor.document.body.innerText = '';
  }
 }
 editor.focus();
}
function FTB_DeleteTableColumn(ftbName) {
 if (FTB_IsHtmlMode(ftbName)) return;
 var td = this.FTB_GetClosest(ftbName,"td");
 if (!td) {
  return;
 }
 var index = td.cellIndex;
 if (td.parentNode.cells.length == 1) {
  //alert("Don't delete last column");
  return;
 }
 // set the caret first to a position that doesn't disappear
 FTB_SelectNextNode(td);
 var rows = td.parentNode.parentNode.rows;
 for (var i = rows.length; --i >= 0;) {
  var tr = rows[i];
  tr.removeChild(tr.cells[index]);
 }
}
function FTB_DeleteTableRow(ftbName) {
 var tr = FTB_GetClosest(ftbName,"tr");
 if (!tr) {
  return;
 }
 var par = tr.parentNode;
 if (par.rows.length == 1) {
  //alert("Don't delete the last row!");
  return;
 }
 // set the caret first to a position that doesn't
 // disappear.
 FTB_SelectNextNode(tr);
 par.removeChild(tr);
}
function FTB_ieSpellCheck(ftbName) {
    if (FTB_IsHtmlMode(ftbName)) return;
 if (!isIE) {
  alert('IE Spell is not supported in Mozilla');
  return;
 }
 try {
  var tspell = new ActiveXObject('ieSpell.ieSpellExtension');
  tspell.CheckAllLinkedDocuments(window.document);
 } catch (err){
  if (window.confirm('You need ieSpell to use spell check. Would you like to install it?')){window.open('http://www.iespell.com/download.php');};
 };

}
function FTB_Indent(ftbName) {
 FTB_Format(ftbName,'indent');
}
function FTB_InsertDate(ftbName) {
 var d = new Date();
 FTB_InsertText(ftbName,d.toLocaleDateString());
}
function FTB_InsertImage(ftbName) {
 if (FTB_IsHtmlMode(ftbName)) return;
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
    editor.document.execCommand('insertimage',1,'');
}
function FTB_InsertRule(ftbName) {
 FTB_Format(ftbName,'inserthorizontalrule');
}
function FTB_InsertTable(ftbName) {
 editor = FTB_GetIFrame(ftbName);
 editor.focus();
 
 var tableWin = window.open("","tableWin","width=400,height=180");
 tableWin.focus();
 
 tableWin.document.body.innerHTML = "";
 tableWin.document.write("<html>\
<head> \
<style type='text/css'> \
html, body { \
  background: ButtonFace; \
  color: ButtonText; \
  font: 11px Tahoma,Verdana,sans-serif; \
  margin: 0px; \
  padding: 0px; \
} \
body { padding: 5px; } \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
button { width: 70px; } \
.space { padding: 2px; } \
 \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
form { padding: 0px; margin: 0px; } \
</style> \
<script language='JavaScript'> \
function insertTable() { \
 cols = parseInt(document.getElementById('f_cols').value); \
 rows = parseInt(document.getElementById('f_rows').value); \
 width = document.getElementById('f_width').value; \
 widthUnit = document.getElementById('f_unit').options[document.getElementById('f_unit').selectedIndex].value; \
 align = document.getElementById('f_align').value; \
 cellpadding = document.getElementById('f_padding').value; \
 cellspacing = document.getElementById('f_spacing').value; \
 border = document.getElementById('f_border').value; \
 window.opener.FTB_CreateTable('" + ftbName + "',cols,rows,width,widthUnit,align,cellpadding,cellspacing,border); \
} \
</script> \
</head> \
<body> \
<form action=''> \
 \
<table border='0' style='padding: 0px; margin: 0px'> \
  <tbody> \
  <tr> \
    <td style='width: 4em; text-align: right'>Rows:</td> \
    <td><input type='text' name='rows' id='f_rows' size='5' title='Number of rows' value='2' /></td> \
    <td></td> \
    <td></td> \
    <td></td> \
  </tr> \
  <tr> \
    <td style='width: 4em; text-align: right'>Cols:</td> \
    <td><input type='text' name='cols' id='f_cols' size='5' title='Number of columns' value='4' /></td> \
    <td style='width: 4em; text-align: right'>Width:</td> \
    <td><input type='text' name='width' id='f_width' size='5' title='Width of the table' value='100' /></td> \
    <td><select size='1' name='unit' id='f_unit' title='Width unit'> \
      <option value='%' selected='1'  >Percent</option> \
      <option value='px'              >Pixels</option> \
      <option value='em'              >Em</option> \
    </select></td> \
  </tr> \
  </tbody> \
</table> \
 \
<fieldset style='float: left; margin-left: 5px;'> \
<legend>Layout</legend> \
 \
<div class='space'></div> \
 \
<div class='fl'>Alignment:</div> \
<select size='1' name='align' id='f_align' \
  title='Positioning of this image'> \
  <option value='' selected='1'                >Not set</option> \
  <option value='left'                         >Left</option> \
  <option value='right'                        >Right</option> \
  <option value='texttop'                      >Texttop</option> \
  <option value='absmiddle'                    >Absmiddle</option> \
  <option value='baseline'                     >Baseline</option> \
  <option value='absbottom'                    >Absbottom</option> \
  <option value='bottom'                       >Bottom</option> \
  <option value='middle'                       >Middle</option> \
  <option value='top'                          >Top</option> \
</select> \
 \
<p /> \
 \
<div class='fl'>Border thickness:</div> \
<input type='text' name='border' id='f_border' size='5' value='1' title='Leave empty for no border' /> \
 \
<div class='space'></div> \
 \
</fieldset> \
 \
<fieldset style='float:right; margin-right: 5px;'> \
<legend>Spacing</legend> \
 \
<div class='space'></div> \
 \
<div class='fr'>Cell spacing:</div> \
<input type='text' name='spacing' id='f_spacing' size='5' value='1' \
title='Space between adjacent cells' /> \
 \
<p /> \
 \
<div class='fr'>Cell padding:</div> \
<input type='text' name='padding' id='f_padding' size='5' value='1' \
title='Space between content and border in cell' /> \
 \
<div class='space'></div> \
 \
</fieldset> \
\
<div style='margin-top: 85px; border-top: 1px solid #999; padding: 2px; text-align: right;'> \
<button type='button' name='ok' onclick='insertTable();window.close();'>Insert</button> \
<button type='button' name='cancel' onclick='window.close();'>Cancel</button> \
</div> \
</


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
ASP.NET使用中一些报错问题发布时间:2022-07-10
下一篇:
ASP.NET:PagedDataSource发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap