一个在线编辑器的问题
它是用JSSCRIPT 做的 (来自www.51js.com)
编辑功能已经实现
问题是:
如何获取内容并发送至服务器
以及如何与其它表单一起发送
其实一句话:
就是如何有ASP中读取在线编辑器中的内容
并将将它作为变量传递
垦请赐教 !!!
我的邮箱:tuozi@21cn.com
或cctctz@163.net
edit.asp代码:
<HTML><HEAD><TITLE>HTML在线编辑器</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="/fav.ico" rel="shortcut icon">
<STYLE type=text/css>BODY {
MARGIN: 25px
}
#all TD {
FONT-SIZE: 12px; LINE-HEIGHT: 15px; FONT-FAMILY: "Verdana", "Arial","新宋体", "宋体"
}
INPUT {
FONT-SIZE: 12px; LINE-HEIGHT: 15px; FONT-FAMILY: "Verdana", "Arial","新宋体", "宋体"
}
SELECT {
FONT-SIZE: 12px; LINE-HEIGHT: 15px; FONT-FAMILY: "Verdana", "Arial","新宋体", "宋体"
}
P {
FONT-SIZE: 12px; LINE-HEIGHT: 15px; FONT-FAMILY: "Verdana", "Arial","新宋体", "宋体"
}
TEXTAREA {
FONT-SIZE: 12px; LINE-HEIGHT: 15px; FONT-FAMILY: "Verdana", "Arial","新宋体", "宋体"
}
#all A:active {
COLOR: #7d070c
}
#all A:visited {
COLOR: #7d070c
}
#all A:hover {
COLOR: #336699
}
#all A:link {
COLOR: #7d070c
}
</STYLE>
<SCRIPT language=JavaScript>
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function JM_cc(ob){
var obj=MM_findObj(ob); if (obj) {
obj.select();js=obj.createTextRange();js.execCommand("Copy");}
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
//-->
</SCRIPT>
<META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
<BODY id=all text=#000000 bgColor=#336699>
<SCRIPT language=javascript>
<!--
function addarticle()
{
CheckForm();
document.add_article.submit();
}
function CheckForm()
{
document.add_article.content.value=document.add_article.editbox.value;
return true
}
//-->
</SCRIPT>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR bgColor=#ffffff>
<TD><IMG height=1 src="space.gif" width=11></TD>
<TD width="100%">
<TABLE cellPadding=8 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle>
<SCRIPT language=JavaScript>
document.write("<font color=#7d070c style=\"font-size: 14px\">"+document.title+"</font>");
</SCRIPT>
</TD></TR>
<TR>
<TD bgColor=#f7f7f7><form method=post onsubmit="return CheckForm()" action=send.asp name=add_article>
标题:<INPUT TYPE="text" NAME="titlesh">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD></TD></TR>
<TR>
<TD></TD></TR>
<TR>
<TD vAlign=top>
<P>
<TABLE class=discussion width="100%">
<TBODY>
<TR>
<TD> <OBJECT id=editbox data=editboxs.htm width="100%"
height=200 type=text/x-scriptlet VIEWASTEXT>
</OBJECT><TEXTAREA style="DISPLAY: none" name=d_message></TEXTAREA>
</TD></TR></TBODY></TABLE><p></P></TD></TR></TBODY></TABLE>
<TEXTAREA style="DISPLAY: none" name="content"></TEXTAREA>
<INPUT id=button1 TYPE="button" value=send onclick=javascript:addarticle(); name=button1></form>
</TD>
</TR>
<TR>
<TD></TD>
</TR></TBODY></TABLE></TD>
<TD><IMG height=1 src="space.gif"
width=11></TD></TR></TBODY></TABLE>
</BODY></HTML>
editboxs.htm代码:
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE>SELECT {
BACKGROUND: #cccccc; FONT: 12px "Verdana,Arial"
}
.toolbar {
BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BACKGROUND: lightgrey; MARGIN-BOTTOM: 3pt; OVERFLOW: hidden; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid; HEIGHT: 28px
}
.mode LABEL {
FONT: bold 12px "Verdana,Arial"
}
.mode .current {
COLOR: darkgreen
}
.heading {
BACKGROUND: lightgrey; COLOR: #006600
}
</STYLE>
<SCRIPT>
var bLoad=false,public_description=new Editor
function Editor() {
this.put_html=put_html;
this.get_html=get_html;
this.testHTML=testHTML
this.bReady = false
}
function cleanupHTML() {
bodyTags=idEdit.document.all[0].all, i
for (i=bodyTags.tags("FONT").length-1;i >= 0;i--)
if (bodyTags.tags("FONT")[i].style.backgroundColor="#ffffff") {
bodyTags.tags("FONT")[i].style.backgroundColor=""
if (bodyTags.tags("FONT")[i].outerHTML.substring(0,6)=="<FONT>")
bodyTags.tags("FONT")[i].outerHTML=bodyTags.tags("FONT")[i].innerHTML
}
}
function testHTML(bAllowHead,extras) {
mW.click()
var badStuff=new Array("F15"),headStuff=new Array("AK47"),hasStuff=new Array(),bodyTags=idEdit.document.body.all,i=0
for (i=0;i<badStuff.length;i++)
if (bodyTags.tags(badStuff[i]).length>0)
hasStuff[hasStuff.length]=badStuff[i]
if (!bAllowHead)
for (i=0;i<headStuff.length;i++)
if (bodyTags.tags(headStuff[i]).length>0)
hasStuff[hasStuff.length]=headStuff[i]
if (extras!=null)
for (i=0;i<extras.length;i++)
if (bodyTags.tags(extras[i]).length>0)
hasStuff[hasStuff.length]=extras[i]
var str=""
if (hasStuff.length>0) {
str="Please remove the following HTML Tags from your message and resubmit:"
for (i=0;i<hasStuff.length;i++)
str+="\n "+hasStuff[i]
str+= "\nRemember, when using HTML Mode you may need to escape \nthe brackets surrounding tags (< and >) with < and >"
setTimeout("mH.click()",0)
}
return str
}
function get_html() {
if (bMode) {
cleanupHTML()
return idEdit.document.all[0].innerHTML
}
else
return idEdit.document.all[0].innerText;
}
function put_html(sVal) {
if (bMode)
idEdit.document.all[0].innerHTML=sVal
else
idEdit.document.all[0].innerText=sVal
}
var sHeader="<link rel=\"stylesheet\" href=\"theme.css\"><BODY STYLE=\"font-family:Verdana; font-size: 12px; letter-spacing: 0px\">",bMode=true,sel=null
//var sHeader="",bMode=true,sel=null
function displayError() {alert("Formatting toolbar is only accessible in WYSIWYG mode");idEdit.focus()}
function format(what,opt) {
if (!bMode) {
displayError()
return
}
if (opt=="removeFormat"){
what=opt;opt=null
}
if (opt=="CustomFont")
opt = prompt("Format your text with what font face?","Geneva, Arial, Sans-Serif")
if ((opt=="") && (what=="forecolor"))
opt = prompt("Format your text with what color?","Black")
if (bMode) {
if (opt==null)
idEdit.document.execCommand(what)
else
idEdit.document.execCommand(what,"",opt)
var s=idEdit.document.selection.createRange(),p=s.parentElement()
idEdit.focus()
}
sel=null
}
function getEl(sTag,start) {
while ((start!=null) && (start.tagName!=sTag))
start = start.parentElement
return start
}
function createLink() {
if (!bMode) {
displayError()
return
}
var isA = getEl("A",idEdit.document.selection.createRange().parentElement())
var str=prompt("请输入你想连接到网址: (例如, http:\/\/www.tantom.com\/)",isA ? isA.href : "http:\/\/")
if ((str!=null) && (str!="http://")) {
if ((idEdit.document.selection.type=="None") && (!isA)) {
var sel=idEdit.document.selection.createRange()
sel.pasteHTML("<A HREF=\""+str+"\">"+str+"</A> ")
sel.select()
}
else
format("CreateLink",str)
}
else
idEdit.focus()
}
//***************************************************
function clearEdit(){
setMode(false)
mH.checked=true;
idEdit.document.open();
idEdit.document.write(sHeader)
idEdit.document.close();
}
function selectAll(){
setMode(false)
idEdit.document.all[0].innerHTML.select();
}
//**************************************************
function setMode(bNewMode) {
if (bNewMode!=bMode) {
if (bNewMode) {
var sContents=idEdit.document.all[0].innerText
//alert(sContents);
idEdit.document.open()
idEdit.document.write(sContents)
idEdit.document.close()
// alert(idEdit.document.all.tags("HTML")[0].innerHTML);
// idEdit.document.all[0].outerHTML=sContents
}
else {
//cleanupHTML()
var sContents=idEdit.document.all.tags("HTML")[0].innerHTML
// alert(sContents.length);
if (sContents.length==82){sContents="";}
idEdit.document.open()
idEdit.document.write(sHeader)
idEdit.document.close()
idEdit.document.body.innerText=sContents
}
bMode=bNewMode
for (var i=0;i<htmlOnly.children.length;i++)
htmlOnly.children[i].disabled=(!bMode)
}
modeA.className=bMode?"current":"";modeB.className=bMode?"":"current"
idEdit.focus()
}
</SCRIPT>
<SCRIPT event=DocumentComplete() for=EditCtrl>
/*if (!bLoad) {
setTimeout("initEditor(true)",0)
idBox.style.visibility=''
idBox.focus()
}*/
bLoad=true
</SCRIPT>
</HEAD>
<BODY onselectstart="return false"
style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; PADDING-BOTTOM: 2pt; MARGIN: 0pt; CURSOR: default; PADDING-TOP: 2pt"
bgColor=#f7f7f7 onload=doLoad()><SPAN id=idBox
style="VISIBILITY: hidden; WIDTH: 100%; TEXT-ALIGN: center">
<TABLE class=toolbar id=tb1 style="MARGIN-BOTTOM: 2pt; PADDING-TOP: 1pt"
cellSpacing=2 cellPadding=0 align=left>
<TBODY>
<TR>
<TD id=htmlOnly vAlign=center noWrap><SELECT
onchange="format('fontname',this[this.selectedIndex].value);this.selectedIndex=0">
<OPTION class=heading selected>Font<OPTION
value=geneva,arial,sans-serif>Arial<OPTION
value=verdana,geneva,arial,sans-serif>Verdana<OPTION
value=times,serif>Times<OPTION value="courier, monospace">Courier<OPTION
style="COLOR: navy" value=CustomFont>Custom...</OPTION></SELECT> <SELECT
onchange="format('fontSize',this[this.selectedIndex].text);this.selectedIndex=0">
<OPTION class=heading
selected>Size<OPTION>1<OPTION>2<OPTION>3<OPTION>4<OPTION>5<OPTION>6<OPTION>7</OPTION></SELECT>
<SELECT
onchange="format('forecolor',this[this.selectedIndex].style.color);this.selectedIndex=0">
<OPTION class=heading selected>Color<OPTION
style="COLOR: black">Black<OPTION style="COLOR: gray">Gray<OPTION
style="COLOR: darkred">Dark Red<OPTION style="COLOR: navy">Navy<OPTION
style="COLOR: darkgreen">Dark Green<OPTION>Custom...</OPTION></SELECT>
</TD></TR></TBODY></TABLE> <object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<script language="javascript">
function print(){
WebBrowser1.ExecWB(6,1);
}
</script>
<!--<IMG SRC=print.gif WIDTH=23 HEIGHT=22 BORDER=0 ALT=打印 style=cursor:hand onclick=print()>-->
<SPAN class=toolbar onselectstart="return false"
id=tb2 ondragstart="return false" style="WIDTH: 270px">
<SCRIPT event="ShowContextMenu(xPos, yPos)" for=EditCtrl>//important</SCRIPT>
<SCRIPT>
var buttons=new Array(24,23,23,4,23,23,23,4,23,23,23,23,4,24),action=new Array("bold","italic","underline","","justifyleft","justifycenter","justifyright","","insertorderedlist","insertunorderedlist","outdent","indent","","createLink"),tooltip=new Array("粗体","斜体","下划线","","向左对齐","向中靠","向右对齐","","列表","取消列表","取消缩进","缩进","","生成网址"),left=0,s=""
for (var i=0;i<buttons.length;i++) {
s+="<SPAN STYLE='position:relative;height:26;width: " + buttons[i] + "'><SPAN STYLE='position:absolute;margin:0px;padding:0;height:26;top:0;left:0;width:" + (buttons[i]) + ";clip:rect(0 "+buttons[i]+" 25 "+0+");overflow:hidden'><IMG BORDER=0 SRC='toolbar.gif' STYLE='position:absolute;top:0;left:-" + left + "' WIDTH=267 HEIGHT=50"
if (buttons[i]!=4) {
s+=" onmouseover='this.style.top=-25' onmouseout='this.style.top=0' ONCLICK=\""
if (action[i]!="createLink")
s+="format('" + action[i] + "');this.style.top=0\" "
else
s+="createLink();this.style.top=0\" "
s+="TITLE=\"" + tooltip[i] + "\""
}
s+="></SPAN></SPAN>"
left+=buttons[i]
}
document.write(s + "</span>")
function initEditor(bWhichEditor) {
// IE5 Secret Sauce
if (bWhichEditor)
idEdit = EditCtrl.DOM.parentWindow
else {
EditCtrl.document.designMode="On"
idEdit = EditCtrl
}
idEdit.document.open()
idEdit.document.write("")
idEdit.document.close()
// alert(idEdit.document.all[0].tagName)
//idEdit.document.all[0].innerHTML=""
// idEdit.document.body.innerText=""
// if (external.raiseEvent)
external.raiseEvent("onready",window.event)
}
function doLoad() {
idBox.style.visibility=''
initEditor(false)
bLoad=true;
idEdit.focus()
//alert(idEdit.document.all[0].tagName);
//alert(idEdit.document.all[0].all.tags("FONT").length)
}
document.write("<IFRAME NAME=EditCtrl WIDTH=100%></IFRAME>")
</SCRIPT>
<TABLE align=left border=0>
<TBODY>
<TR>
<TD align=left><SPAN class=mode id=tb3><INPUT id=mW onclick=setMode(true)
type=radio CHECKED name=rMode> <LABEL class=current id=modeA
for=mw>DREAMWEAVER编辑状态</LABEL> <INPUT id=mH onclick=setMode(false)
type=radio name=rMode> <LABEL id=modeB for=mH>显示源代码</LABEL></SPAN></SPAN>
<SCRIPT>
setTimeout("document.all.EditCtrl.style.height=document.body.offsetHeight-90",0)
window.onresize = new Function("document.all.EditCtrl.style.height=document.body.offsetHeight-90")
</SCRIPT>
</SPAN></TD></TR></TBODY></TABLE></SPAN></SPAN></BODY></HTML>
send.asp代码:
<%
titlesh=request("titlesh")
bodys=request.form("content")
sql="insert into xiaoxi(titlesh,bodys) values('"&titlesh&"','"&bodys&"')"
response.write sql
%>
请问:发送之后为什么bodys 传出的结果为:undefined
垦请赐教
问题点数:20、回复次数:3Top
1 楼kingzeus(Kingzeus)回复于 2001-05-25 11:57:00 得分 0
关注Top
2 楼net_lover(【孟子E章】)回复于 2001-05-25 13:14:00 得分 20
把
ocument.add_article.editbox.value
改为:
ocument.add_article.editbox.htmlTop
3 楼chuting(学习的动力)回复于 2001-05-26 15:32:00 得分 0
多谢孟子E章!
有空调试一下,好了请你吃大餐
Top




