📄 add_product.asp
字号:
text="this.render\n\n";
for(i=0;i<this.controlNames.length;i++){
text = text + "\t" + this.controlNames[i] + "\n";
}
if (this.isRichText) {
this._renderRTE(html);
} else {
this._renderDefault(html);
}
}
this._renderDefault = function(html){
//alert("this._renderDefault");
document.writeln('<textarea name="' + this.name + '" id="' + this.name + '" style="width: ' + this.width + 'px; height: ' + this.height + 'px;">' + html + '</textarea>');
}
this.getControlNames = function(lable){
text= lable + "\n\n";
for(i=0;i<this.controlNames.length;i++){
text = text + "\t" + this.controlNames[i] + "\n";
}
return text;
}
this._renderControls = function(){
//alert("this._renderControls");
text = "";
for(x=0;x<this.controlNames.length;x++){
control = this.controlsByName[this.controlNames[x]];
if(control){
text = text + control.getRenderedText();
}
}
text = text + '</tr>';
text = text + '</table>';
document.writeln(text);
}
this._renderRTE = function(){
//alert("this._renderRTE");
document.writeln('<style type="text/css">');
document.writeln('.btnImage {cursor: pointer; cursor: hand;}');
document.writeln('</style>');
this._renderControls();
document.writeln('<iframe id="' + this.name + '" width="' + this.width + 'px" height="' + this.height + 'px"></iframe>');
//document.writeln('<br /><input type="checkbox" id="chkSrc' + this.name + '" onclick="HyperTextArea.getArea(\''+this.name+'\').toggleHTMLSrc();" /> 查看HTML代码');
//reimplement this so that it is not in an iframe, rather in a div.
document.writeln('<iframe width="145" height="130" id="cp' + this.name + '" name="cp' + this.name + '" marginwidth="0" marginheight="0" scrolling="no" style="visibility:hidden; position: absolute;"></iframe>');
document.writeln('<input type="hidden" id="hdn' + this.name + '" name="' + this.name + '" value="">');
document.getElementById('hdn' + this.name).value = this.html;
this.setContent(this.html);
setTimeout('onHyperTextAreaLoad(\'' + this.name + '\')', 500);
}
this.setContent = function(html){
//alert("this.setContent");
HyperTextArea.activeArea = this;
var frameHtml = "<html>\n";
frameHtml += "<head>\n";
if (this.styleSheetUrl){
frameHtml += "<link media=\"all\" type=\"text/css\" href=\"style.css\" rel=\"stylesheet\">\n";
}
frameHtml += "</head>\n";
frameHtml += "<body>\n";
frameHtml += html;
frameHtml += "</body>\n";
frameHtml += "</html>";
if (document.all) {
var oRTE = frames[this.name].document;
oRTE.open();
oRTE.write(frameHtml);
oRTE.close();
} else {
var oRTE = document.getElementById(this.name).contentWindow.document;
oRTE.open();
oRTE.write(frameHtml);
oRTE.close();
//attach a keyboard handler for Mozilla to make keyboard shortcuts for formatting text work
oRTE.addEventListener("keypress", kb_handler, true);
}
}
this.update = function(){
//alert("this.update");
this.setViewMode(false);
//set message value
var oHdnMessage = document.getElementById('hdn' + this.name);
var oRTE = document.getElementById(this.name);
if (this.isRichText) {
if (oHdnMessage.value == null) oHdnMessage.value = "";
if (document.all) {
oHdnMessage.value = frames[this.name].document.body.innerHTML;
} else {
oHdnMessage.value = oRTE.contentWindow.document.body.innerHTML;
}
//if there is no content (other than formatting) set value to nothing
if (stripHTML(oHdnMessage.value.replace(" ", " ")) == "") oHdnMessage.value = "";
this.html = stripWordHTML(oHdnMessage.value);
}
}
this.setToolbarsVisible = function(isVisible){
//alert("this.setToolbarsVisible");
visibleStyle = isVisible?"visible":"hidden";
for (x=0;x<this.toolbarNames.length;x++){
document.getElementById(this.toolbarNames[x] + "_" + this.name).style.visibility = visibleStyle;
}
}
this.setViewMode = function(isSrcView){
//alert("this.setViewMode");
HyperTextArea.activeArea = this;
//contributed by Bob Hutzel (thanks Bob!)
var oRTE;
if (document.all) {
oRTE = frames[this.name].document;
} else {
oRTE = document.getElementById(this.name).contentWindow.document;
}
//only change the view if it is different than the current state
if (isSrcView && !this.isSrcView){
this.isSrcView = true;
this.setToolbarsVisible(false);
if (document.all) {
oRTE.body.innerText = oRTE.body.innerHTML;
} else {
var htmlSrc = oRTE.createTextNode(oRTE.body.innerHTML);
oRTE.body.innerHTML = "";
oRTE.body.appendChild(htmlSrc);
}
}else if(!isSrcView && this.isSrcView){
this.isSrcView = false;
this.setToolbarsVisible(true);
if (document.all) {
oRTE.body.innerHTML = oRTE.body.innerText;
} else {
var htmlSrc = oRTE.body.ownerDocument.createRange();
htmlSrc.selectNodeContents(oRTE.body);
oRTE.body.innerHTML = htmlSrc.toString();
}
}
}
this.toggleHTMLSrc = function(){
//alert("this.toggleHTMLSrc");
if (document.getElementById("chkSrc" + this.name).checked) {
this.setViewMode(true);
} else {
this.setViewMode(false);
}
}
//TODO would really like to be able to plug functionality in here.
//This would include the ability to launch a wizard, and then insert arbitrary text at the insertion point
this.formatText = function (command,option){
//alert("this.formatText");
//所有与文字处理有关的功能都会调用此方法,在这个方法里面可以添加相关的新功能
HyperTextArea.activeArea = this;
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
if ((command == "forecolor") || (command == "backcolor")) {
this.command = command;
controlElement = document.getElementById(this.name +"_" + command);
//获得颜色选择窗口
cp = document.getElementById('cp' + this.name);
this.cpWindow.area = this;
cp.style.left = getOffsetLeft(controlElement) + "px";
cp.style.top = (getOffsetTop(controlElement) + controlElement.offsetHeight) + "px";
if (cp.style.visibility == "hidden") {
//打开颜色选择窗口
cp.style.visibility="visible";
} else {
cp.style.visibility="hidden";
}
//get current selected range
var sel = oRTE.document.selection;
if (sel != null) {
this.rng = sel.createRange();
//alert(this.rng.text);
}
} else if (command == "createlink") {
//TODO need a way to make this more flixible.
//Would especially like to be able to insert a link with both the containing text and the URL
var szURL = prompt("Enter a URL:", "");
oRTE.document.execCommand("Unlink",false,null)
oRTE.document.execCommand("CreateLink",false,szURL)
} else if (command == 'paste') {
oRTE.focus();
oRTE.document.execCommand(command);
oRTE.focus();
} else {
oRTE.focus();
oRTE.document.execCommand(command, false, option);
oRTE.focus();
}
}
this.setColor = function(color){
//选择前景色与背景色时调用
HyperTextArea.activeArea = this;
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
if (document.all) {
//得到选定矩形
var sel = oRTE.document.selection;
if (sel != null) {
var newRng = sel.createRange();
newRng = this.rng;
newRng.select();
}
} else {
oRTE.focus();
}
//设置文本前景或背景颜色
oRTE.document.execCommand(this.command, false, color);
oRTE.focus();
//关闭颜色选择窗口
document.getElementById('cp' + this.name).style.visibility = "hidden";
}
this.addImage = function(imagePath){
//alert("this.addImage");
HyperTextArea.activeArea = this;
if(!imagePath){
imagePath = prompt('Enter Image URL:', 'http://');
}
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
if ((imagePath != null) && (imagePath != "")) {
oRTE.focus()
oRTE.document.execCommand('InsertImage', false, imagePath);
}
oRTE.focus()
}
//TODO should look into ways to make this cross browser and platform
this.checkspell = function(){
//alert("this.checkspell");
try {
var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
tmpis.CheckAllLinkedDocuments(document);
}
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");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -