📄 edit1.asp
字号:
catch(exception) {
if(exception.number==-2146827859) {
if (confirm("ieSpell not detected. Click OK to go to download page."))
window.open("http://www.iespell.com/download.php","DownLoad");
} else {
alert("Error Loading ieSpell: Exception " + exception.number);
}
}
}
this.select = function(menu,cmd){
//alert("this.select");
HyperTextArea.activeArea = this;
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
var idx = menu.selectedIndex;
// First one is always a label
if (idx != 0) {
var selected = menu.options[idx].value;
oRTE.document.execCommand(cmd, false, selected);
menu.selectedIndex = 0;
}
oRTE.focus();
}
//用于插入表格地弹出窗口
this.insertTableDialog = function(){
w = window.open("","tableDialog","top=300,left=300,width=300,height=150");
w.area = this;
d = w.document;
d.open();
d.write(getTableDialogAsString());
d.close();
}
this.insertTable = function(rows,cols,spacing,padding,border){
rows = rows||3;
cols = cols||3;
spacing = spacing||2;
padding = padding||2;
if(border == true){
border = 1;
}
border = border||0;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
doc = oRTE.document;
table = doc.createElement("table");
table.setAttribute("border", border);
table.setAttribute("cellpadding", padding);
table.setAttribute("cellspacing", spacing);
table.setAttribute("class", "hyperTable");
for (var i=0; i < rows; i++) {
var tr = doc.createElement("tr");
for (var j=0; j < cols; j++) {
var td = doc.createElement("td");
var content = doc.createTextNode('\u00a0');
td.appendChild(content);
tr.appendChild(td);
}
table.appendChild(tr);
}
this.insertElement(table);
}
this.insertElement = function(el){
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
doc = oRTE.document;
if (document.all) {
selection = doc.selection;
var html = el.outerHTML;
var range = selection.createRange();
try {
range.pasteHTML(html);
} catch (e) {
// catch error when range is evil for IE
}
}else{
selection = oRTE.getSelection();
var range = selection.getRangeAt(0);
selection.removeAllRanges();
range.deleteContents();
var container = range.startContainer||selection.focusNode;
var pos = range.startOffset;
afterNode = container.childNodes[pos];
try{
container.insertBefore(el, container.afterNode);
}catch (e){
//if this is a text node, then break it up into a text node, new element, text node
if(container.nodeName.toLowerCase() == "#text"){
text0 = container.data.substring(0,range.startOffset);
text1 = container.data.substring(range.startOffset,container.data.length-1);
container.data = text0;
parent = container.parentNode;
parent.insertBefore(el,container.nextSibling);
newTextNode = document.createTextNode(text1);
parent.insertBefore(newTextNode,el.nextSibling);
}else {
alert(el.nodeName.toLowerCase() + " cannot be placed here for the following reason:\n\n" + e);
}
}
}
}
this.init();
if(!this.delayRender){
this.render(this.html);
}
}
function TextFormatButton(name,label,icon,command,option){
this.name = name;
this.label = label;
this.icon = icon;
this.command = command;
this.option = option||"";
//the next two values are set by the HyperTextArea object
this.area = null;
this.resourcePath = null;
this.getRenderedText = function(){
text = '<td><div id="'+this.area.name+'_'+this.name+'">'
text = text + '<img class="btnImage" src="'+this.resourcePath+this.icon+'" width="25" height="24" alt="'+this.label+'" title="'+this.label+'" onClick="HyperTextArea.getArea(\''+ this.area.name +'\').getControl(\''+this.name+'\').execute()">';
text = text + '</div></td>';
return text;
}
this.execute = function(){
this.area.formatText(this.command,this.option);
}
}
function Button(name,icon,title,methodName){
this.name=name;
this.getRenderedText = function(){
text = '<td><div id="'+name+'">'
text = text + '<img class="btnImage" src="'+this.resourcePath+icon+'" width="25" height="24" alt="'+title+'" title="'+title+'" onClick="HyperTextArea.getArea(\''+ this.area.name +'\').'+methodName+'()">';
text = text + '</div></td>';
return text;
}
}
function Spacer(name){
this.name = name
this.getRenderedText = function(){
return '<td> </td>'
}
}
function Toolbar(name, isFirstToolbar){
this.name = name
this.isFirstToolbar = isFirstToolbar||false;
this.getRenderedText = function(){
this.area.toolbarNames[this.area.toolbarNames.length] = this.name;
text = '<table id="' + this.name + '_' + this.area.name + '" cellpadding="1" cellspacing="0"><tr>'
if(this.isFirstToolbar){
text = '</tr></table>\n' + text;
}
return text;
}
}
function Menu(name,cmd){
this.name = name;
this.cmd = cmd;
this.area = null;
this.items = new Array();
this.addItem = function(value,lable){
this.items[this.items.length] = new MenuItem(value,lable);
}
this.addItems = function(){
for (i=0;i<arguments.length;i=i+2){
this.addItem(arguments[i],arguments[i+1]);
}
}
this.getRenderedText = function(){
text = "<td><select name='"+this.name+"' id='"+this.name+"_"+this.area.name+"' onchange='HyperTextArea.getArea(\""+ this.area.name +"\").select(this,\""+this.cmd+"\");'>\n";
for (i=0;i<this.items.length;i++){
thisItem = this.items[i]
text = text + "<option value='"+thisItem.value+"'>"+thisItem.lable+"</option>\n";
}
text = text + "</select></td>";
return text;
}
}
function MenuItem(value,lable){
this.value = value;
this.lable = lable;
}
HyperTextArea.areas = new Array();
HyperTextArea.getArea = function(name){
return HyperTextArea.areas[name];
}
HyperTextArea.activeArea = null;
HyperTextArea.about = function(){
var area;
for(i in HyperTextArea.areas){
area = HyperTextArea.getArea(i);
break;
}
window.open(area.resourcePath + "about.html");
}
HyperTextArea.updateAllAreas = function(){
//iterate over all areas and call update
for(i in HyperTextArea.areas){
area = HyperTextArea.areas[i];
area.update();
}
}
HyperTextArea.forms = new Array();
function getOffsetTop(elm) {
var mOffsetTop = elm.offsetTop;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent){
mOffsetTop += mOffsetParent.offsetTop;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetTop;
}
function getOffsetLeft(elm) {
var mOffsetLeft = elm.offsetLeft;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent) {
mOffsetLeft += mOffsetParent.offsetLeft;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetLeft;
}
function kb_handler(evt, rte) {
//contributed by Anti Veeranna (thanks Anti!)
if (evt.ctrlKey) {
var key = String.fromCharCode(evt.charCode).toLowerCase();
var cmd = '';
switch (key) {
case 'b': cmd = "bold"; break;
case 'i': cmd = "italic"; break;
case 'u': cmd = "underline"; break;
};
if (cmd) {
evt.target.ownerDocument.execCommand(cmd,false,true);
// stop the event bubble
evt.preventDefault();
evt.stopPropagation();
}
}
}
function stripWordHTML(oldString) {
var newString = oldString;
//清理word,excel里面复制过来的table html垃圾代码
newString = newString.replace("x:str", "");
newString = newString.replace("border=0", "border=1");
newString = newString.replace(/<(\w[^>]*) style="([^"]*)"/gi, "<$1")
newString = newString.replace(/<\/?SPAN[^>]*>/gi, "" ); //Remove all SPAN tags
newString = newString.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;// Remove Lang attributes
newString = newString.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");// Remove Class attributes
//newString = newString.replace(/'/g, "'");
//trim string
newString = trim(newString);
return newString;
}
function stripHTML(oldString) {
var newString = oldString.replace(/(<([^>]+)>)/ig,"");
//replace carriage returns and line feeds
newString = escape(newString)
newString = newString.replace("%0D%0A"," ");
newString = newString.replace("%0A"," ");
newString = newString.replace("%0D"," ");
newString = unescape(newString)
//trim string
newString = trim(newString);
return newString;
}
function trim(inputString) {
// Removes leading and trailing spaces from the passed string. Also removes
// consecutive spaces and replaces it with one space. If something besides
// a string is passed in (null, custom object, etc.) then return the input.
if (typeof inputString != "string") { return inputString; }
var retValue = inputString;
var ch = retValue.substring(0, 1);
while (ch == " ") { // Check for spaces at the beginning of the string
retValue = retValue.substring(1, retValue.length);
ch = retValue.substring(0, 1);
}
ch = retValue.substring(retValue.length-1, retValue.length);
while (ch == " ") { // Check for spaces at the end of the string
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings
}
return retValue; // Return the trimmed string back to the user
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -