📄 add_product.asp
字号:
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
}
function getPaletteAsString(){
hexArray = new Array("00","55","AA","FF");
out = "";
out2 = "";
line = ""
row = 1;
count = 1;
for(i=hexArray.length-1;i>=0;i--){
val0 = hexArray[i];
for(j=hexArray.length-1;j>=0;j--){
val1 = hexArray[j];
for(k=hexArray.length-1;k>=0;k--){
val2 = hexArray[k];
hexVal = val0+val1+val2;
line = line + "\n <td id='#"+hexVal+"' bgcolor='#"+hexVal+"' width='15' height='15' onmouseover='this.style.border=\"1px dotted white\"' onclick='area.setColor(this.id)'><img width='1' height='1'></td>";
if(count==1 || (row % 2) == 0){
if(((count - 1) % 8) == 0){
out = out + "\n<tr>";
row++
}
out = out + line;
if((count % 8) == 0){
out = out + "\n</tr>";
}
}else{
if(((count - 1) % 8) == 0){
out2 = out2 + "\n<tr>";
row++
}
out2 = out2 + line;
if((count % 8) == 0){
out2 = out2 + "\n</tr>";
}
}
line = "";
count++;
}
}
}
out = '<table cellpadding="0" cellspacing="1" border="1" align="center">' + out + out2 + "</table>";
return out;
}
function getTableDialogAsString(){
out = '<html><body><form name="tableDialog">';
out = out + '<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#BDD7F7"><tr><td>';
out = out + '<table width="100%" cellpadding="2" cellspacing="2" border="0" bgcolor="#FFFFFF">';
out = out + '<tr bgcolor="#eff7ff">';
out = out + '<td colspan=2 align=center><font size=2px>插入表格</font></td>';
out = out + '</tr>';
out = out + '<tr bgcolor="#ffffde">';
out = out + '<td align=center><font size=2px>行数:</font></td><td align=center><font size=2px>列数:</font></td>';
out = out + '</tr>';
out = out + '<tr bgcolor="#ffffde">';
out = out + '<td align=center><input type="text" name="rows" size="7" value="3"/></td>';
out = out + '<td align=center><input type="text" name="cols" size="7" value="3"/></td>';
out = out + '<tr bgcolor="#ffffde">';
out = out + '<td colspan=2 align=center><input type="button" name="button" value="确定" onclick="window.opener.HyperTextArea.activeArea.insertTable(this.form.rows.value,this.form.cols.value,2,2,true);self.close()"/> <input type="button" name="cancel" value="取消" onclick="self.close()"/></td>';
out = out + '</tr>';
out = out + '</table>';
out = out + '</td></tr></table>';
out = out + '</form></body></html>';
return out;
}
function enableDesignMode(areaName){
try{
if (document.all) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -