我图片上传成功。想让图片在在线编缉器中显示。怎么获得在线编缉器,
下边是添加页面。
<table cellpadding="3" cellspacing="1" align="center" class="tableBorder w97 tc b0">
<tr>
<td class="title h30 tc" colspan="2">增 加 产 品 内 容</td>
</tr>
<tr>
<td class="title2 h30" colspan="2">选择您需要更改的产品信息。</td>
</tr>
<tr>
<td class="table h25 trs w115">编号:</td>
<td class="table TL"><input type="text" id="bian" name="bian" /> <font color="#FF0000">*</font>如:<font color="#a0a0a0" face="Arial">TEX001</font>(<font color="#FF0000">*</font>为必填项)</td>
</tr>
<tr>
<td class="table h25 trs">品名:</td>
<td class="table TL"><input type="text" id="ping" name="ping" /> <font color="#FF0000">*</font></td>
</tr>
<tr>
<td class="table h25 trs">产品类别:</td>
<td class="table TL">
大类:<select id="Select1" runat="server" onchange="ShowTable(this.options[selectedIndex].value);"></select>
小类:<select id="Select2" runat="server" ></select> <font color="#FF0000">*</font>
</td>
</tr>
<tr>
<td height="25" align="right" valign="top" class="table">规格:</td>
<td class="table TL tv"><input type="text" id="gui" name="gui" /></td>
</tr>
<tr>
<td class="table h25 trs">起订量:</td>
<td class="table TL"><input type="text" id="qi" name="qi" /></td>
</tr>
<tr>
<td class="table h25 trs">市场价:</td>
<td class="table TL"><input type="text" id="Sjia" name="Sjia" /></td>
</tr>
<tr>
<td class="table h25 trs">祺汇价:</td>
<td class="table TL"><input type="text" id="Qjia" name="Qjia" /></td>
</tr>
<tr>
<td class="table h25 trs">产品介绍:</td>
<td class="table TL">
<iframe id="producstj" width="60%" hidefocus="hideFocus" tabindex="5" name="producstj" src="../editor/editor.htm" frameborder="0"></iframe>这是编缉器。
</td>
</tr>
<tr>
<td class="table h25 trs">当前时间:</td>
<td class="table TL"><asp:Label ID="times" runat="server" Text="Label"></asp:Label></td>
</tr>
<tr>
<td class="table h25 trs">新品上市:</td>
<td class="table TL">
<input id="Radio1" name="xin" type="radio" value="1" checked="checked" /> 是 <input id="Radio2" name="xin" type="radio" value="0" /> 否
<font color="#FF0000">*设置在首页为新品上市显示</font></td>
</tr>
<tr>
<td class="table h25 trs">推荐产品:</td>
<td class="table TL">
<input id="Radio3" name="tui" type="radio" value="1" /> 是 <input id="Radio4"
name="tui" type="radio" value="0" checked="checked" /> 否
<font color="#FF0000">*设置在首页为推荐产品显示</font></td>
</tr>
<tr>
<td colspan="2" class="table h30 tc">
<input type="submit" name="Submit" value="提交" class="btn" onclick="sub();" />
<input type="reset" name="reset" value="重置" class="btn" />
</td>
</tr>
</table> 这个是上传图片页面,能上传成功,关键是怎么把上传的址址给编缉器,
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="img2.aspx.cs" Inherits="HtmlEditor_editor_img2" %><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>插入图片</title>
<style type="text/css">
body, td, span, div, input,form {
font-size: 12px;
font-family: "宋体", "Courier New", Courier, monospace;
margin: 0px;
}
</style>
<script language="JavaScript" type="text/javascript">
<!--
window.isIE = (navigator.appName == "Microsoft Internet Explorer");
if(window.isIE) {
if(navigator.userAgent.indexOf("Opera")>-1) window.isIE = null;
}
else {
if(navigator.userAgent.indexOf("Gecko")==-1) window.isIE = null;
}
function $(sID) {
return document.getElementById(sID);
}
function adjustDialog(){
var w = $("tabDialogSize").offsetWidth + 6;
var h = $("tabDialogSize").offsetHeight + 25;
window.dialogLeft = (screen.availWidth - w) / 2;
window.dialogTop = (screen.availHeight - h) / 2;
}
window.onload = init;
function init () {
var k;
adjustDialog();
//$("imgpath").select();
}
function LoadIMG(imgpath){
下边是添加页面。
<table cellpadding="3" cellspacing="1" align="center" class="tableBorder w97 tc b0">
<tr>
<td class="title h30 tc" colspan="2">增 加 产 品 内 容</td>
</tr>
<tr>
<td class="title2 h30" colspan="2">选择您需要更改的产品信息。</td>
</tr>
<tr>
<td class="table h25 trs w115">编号:</td>
<td class="table TL"><input type="text" id="bian" name="bian" /> <font color="#FF0000">*</font>如:<font color="#a0a0a0" face="Arial">TEX001</font>(<font color="#FF0000">*</font>为必填项)</td>
</tr>
<tr>
<td class="table h25 trs">品名:</td>
<td class="table TL"><input type="text" id="ping" name="ping" /> <font color="#FF0000">*</font></td>
</tr>
<tr>
<td class="table h25 trs">产品类别:</td>
<td class="table TL">
大类:<select id="Select1" runat="server" onchange="ShowTable(this.options[selectedIndex].value);"></select>
小类:<select id="Select2" runat="server" ></select> <font color="#FF0000">*</font>
</td>
</tr>
<tr>
<td height="25" align="right" valign="top" class="table">规格:</td>
<td class="table TL tv"><input type="text" id="gui" name="gui" /></td>
</tr>
<tr>
<td class="table h25 trs">起订量:</td>
<td class="table TL"><input type="text" id="qi" name="qi" /></td>
</tr>
<tr>
<td class="table h25 trs">市场价:</td>
<td class="table TL"><input type="text" id="Sjia" name="Sjia" /></td>
</tr>
<tr>
<td class="table h25 trs">祺汇价:</td>
<td class="table TL"><input type="text" id="Qjia" name="Qjia" /></td>
</tr>
<tr>
<td class="table h25 trs">产品介绍:</td>
<td class="table TL">
<iframe id="producstj" width="60%" hidefocus="hideFocus" tabindex="5" name="producstj" src="../editor/editor.htm" frameborder="0"></iframe>这是编缉器。
</td>
</tr>
<tr>
<td class="table h25 trs">当前时间:</td>
<td class="table TL"><asp:Label ID="times" runat="server" Text="Label"></asp:Label></td>
</tr>
<tr>
<td class="table h25 trs">新品上市:</td>
<td class="table TL">
<input id="Radio1" name="xin" type="radio" value="1" checked="checked" /> 是 <input id="Radio2" name="xin" type="radio" value="0" /> 否
<font color="#FF0000">*设置在首页为新品上市显示</font></td>
</tr>
<tr>
<td class="table h25 trs">推荐产品:</td>
<td class="table TL">
<input id="Radio3" name="tui" type="radio" value="1" /> 是 <input id="Radio4"
name="tui" type="radio" value="0" checked="checked" /> 否
<font color="#FF0000">*设置在首页为推荐产品显示</font></td>
</tr>
<tr>
<td colspan="2" class="table h30 tc">
<input type="submit" name="Submit" value="提交" class="btn" onclick="sub();" />
<input type="reset" name="reset" value="重置" class="btn" />
</td>
</tr>
</table> 这个是上传图片页面,能上传成功,关键是怎么把上传的址址给编缉器,
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="img2.aspx.cs" Inherits="HtmlEditor_editor_img2" %><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>插入图片</title>
<style type="text/css">
body, td, span, div, input,form {
font-size: 12px;
font-family: "宋体", "Courier New", Courier, monospace;
margin: 0px;
}
</style>
<script language="JavaScript" type="text/javascript">
<!--
window.isIE = (navigator.appName == "Microsoft Internet Explorer");
if(window.isIE) {
if(navigator.userAgent.indexOf("Opera")>-1) window.isIE = null;
}
else {
if(navigator.userAgent.indexOf("Gecko")==-1) window.isIE = null;
}
function $(sID) {
return document.getElementById(sID);
}
function adjustDialog(){
var w = $("tabDialogSize").offsetWidth + 6;
var h = $("tabDialogSize").offsetHeight + 25;
window.dialogLeft = (screen.availWidth - w) / 2;
window.dialogTop = (screen.availHeight - h) / 2;
}
window.onload = init;
function init () {
var k;
adjustDialog();
//$("imgpath").select();
}
function LoadIMG(imgpath){
var editor = window.dialogArguments.productj;
var oRTE = editor.iframe.HtmlEditor;
var html = "<img name='loadimgs'border=0 vspace=4 src='" + imgpath + "'>";
// if(window.isIE) {
// try{
oRTE.focus();
var oRng = oRTE.document.selection.createRange();
oRng.pasteHTML(html);
oRng.collapse(false);
oRng.select();
alert(oRng.value);
// }
// catch(e){}
// }
// else {
// editor.runCMD('insertHTML', html);
// }
alert("上传成功!");
window.close();
}
function chk_imgpath () {
if($('radio1').checked==true){
if($("imgpath").value == "http://" || $("imgpath").value == "") {
window.close();
return;
}
LoadIMG($("imgpath").value);
}else{
if($('<%=this.FileUpload1.ClientID %>').value == "") {
window.close();
return;
}
//$('form1').submit();
$('<%=this.Button1.ClientID %>').click();
$('divProcessing').style.display='';
}
}
document.onkeydown = function (el) {
var event = window.event || el;
if(event.keyCode == 13) {
chk_imgpath();
}
}
//-->
</script>
</head>
<body>
<form id="form1" runat="server">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="tabDialogSize">
<tr>
<td height="24" bgcolor="#DDE7EE" style="padding-left: 10px;">插入图片</td>
</tr>
<tr>
<td height="50"><input type="radio" name="picurl" id="radio1" hidefocus="true" onClick="if(this.checked==true){$('imgpath').disabled='';$('<%=this.FileUpload1.ClientID %>').disabled='disabled';}"> 图片地址:
<input type="text" value="http://" style="border: 1px solid #999999; width: 235px;" id="imgpath" name="imgpath" disabled="disabled"></td>
</tr>
<tr height="30">
<td align="left" id="upid" width="400"><input type="radio" id="radio2" name="picurl" hidefocus="true" onClick="if(this.checked==true){$('imgpath').disabled='disabled';$('<%=this.FileUpload1.ClientID %>').disabled='';}" checked> 上传图片:
<asp:FileUpload ID="FileUpload1" runat="server" style="width:300px; border:#999999 1px solid" /><asp:Label
ID="Label1" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td style="padding: 10px;"> </td>
</tr>
<tr>
<td height="40" align="center" style="padding-bottom: 10px;"><a href="#" id="mysubmit" onClick="chk_imgpath()"><img border="0" src="../images/dilog_bt_ok.gif" alt="确定" style="margin-right: 10px;"/></a><a href="#" onClick="window.close();"><img border="0" src="../images/dilog_bt_cancel.gif" alt="取消"/></a><asp:Button
ID="Button1" style="display:none;" runat="server" OnClick="Button1_Click" Text="Button" /></td>
</tr><tr><td bgcolor="#DDE7EE" height="5"></td>
</tr>
</table>
<div id=divProcessing style="width:200px;height:30px;position:absolute;left:85px;top:75px;display:none">
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#333333" width="100%" height="100%">
<tr>
<td bgcolor="#3A6EA5" align="center"><font color=#FFFFFF>图片上传中,请等待...</font></td>
</tr>
</table>
</div>
</form>
</body>
</html>
var iObj = document.getElementById("productj").contentWindow
var pro=iObj.frames["HtmlEditor"];
alert(pro.$("ifpro").innerHTML);
添加页面里有
<iframe id="producstj" width="60%" hidefocus="hideFocus" tabindex="5" name="producstj" src="../editor/editor.htm" frameborder="0"> </iframe>
而editor.htm页面里有
<SCRIPT language=JavaScript>
<!--
if(document.all){document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" id="divEditor"><tr><td style=""><IFRAME class="HtmlEditor" ID="HtmlEditor" name="HtmlEditor" style="height:100%;width:100%" frameBorder="0" marginHeight=0 marginWidth=0 src="about:blank"></IFRAME></td></tr></table>')}else{document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" id="divEditor"><tr><td style="background-color:#ffffff"><IFRAME class="HtmlEditor" ID="HtmlEditor" name="HtmlEditor" style="height:100%;width:100%;margin-left:1px;margin-bottom:1px;" frameBorder="0" marginHeight=0 marginWidth=0 src="about:blank"></IFRAME></td></tr></table>')}
//-->
</SCRIPT>这个的作用就是编缉文本所在的iframe
s111=ct.$("editor_body_area").contentWindow.document.body.innerHTML;
我用这两句把编缉器的值给取回来了。但是,我点插入图片,弹出的插入图片对话框,把上传的图片地址,再传到编缉器又出问题了。
在弹出对话框这个页面,我无法获得父页的编缉器。高手指点一下。
function LoadIMG(imgpath){这个就是上传图片的地址参数
var editor = parent.window.$("Editor").contentWindow;主要是这句,怎么取得父页的编缉器。。
//s111=ct.$("editor_body_area").contentWindow.document.body.innerHTML;
//var editor=document.body.innerHTML;
alert(editor.value);
// var oRTE = editor.iframe.contentWindow;
// var html = "<img name='loadimgs'border=0 vspace=4 src='" + imgpath + "'>";
// if(window.isIE) {
// try{
// oRTE.focus();
// var oRng = oRTE.document.selection.createRange();
// oRng.pasteHTML(html);
// oRng.collapse(false);
// oRng.select();
// }
// catch(e){}
// }
// else {
// editor.runCMD('insertHTML', html);
// }
//window.close();
}