我自己弄了个别人在线编译文本,因为本来的没有图片上传功能,所以我把1.6.3的上传图片的FTB.IMAGEGALLERY.ASPX弄了过来,可是弄过来了,图片可以上传,可是点际图片的时候没有反应,正常的话应该可以自己插到编辑区域的啊;
调用FTB.IMAGEGALLERY.ASPX页的代码:url = showModalDialog("comm/uploadimage.htm","window","dialogWidth:640pt;dialogHeight:500pt;status:0");
这里的URL要是为这样的形式的话http://www.hao123.com/masjf.gif
或别的什么AFA.GIF的时候都是正常的.
我的问题就是怎么showModalDialog("comm/ftb.imagegallery.aspx","window","dialogWidth:640pt;dialogHeight:500pt;status:0");没有返回值????
showModalDialog打開的文檔對象中要調用
window.returnValue來設置返回值
showmodaldialog的窗口有个属性是returnvalue,这个值是返回值。
要在你showdialog的页面中加这个东东。
<script language="javascript">
function ReturnValue()
{
var parwin = window.dialogArguments;
parwin.document.all.txtPersonName.value=document.all.txtValue.value;
parwin.document.all.txtPersonNo.value=document.all.txtUser.value;
window.close();
}
</script>
ftb.imagegallery.aspx里有句话:
myImageHolder.Attributes["ondblclick"]="returnImage(" + ImageFileLocation.Replace("\\","/") + "," + myImage.Width.ToString() + "," + myImage.Height.ToString() + ");";
他的作用是双击事件发生的时候,触发 returnImage(imagename,width,height) 事件来返回值的,返回的时候返回的数组如下:
<SCRIPT LANGUAGE="JavaScript">
<!--
function returnImage(imagename,width,height) {
var arr = new Array();
arr["filename"] = imagename;
arr["width"] = width;
arr["height"] = height;
window.parent.returnValue = arr;
window.parent.close();
}
//-->
</SCRIPT>
返回到页面后取得返回的数组,插入图片OK
<SCRIPT LANGUAGE="JavaScript">
<!--
function InsertPic()
{
if (!validateMode())
{
return;
}
HtmlEdit.focus();
var range = HtmlEdit.document.selection.createRange();
var arr = showModalDialog("InsertPic.aspx?<%=Request.QueryString%>", window,"dialogWidth:300px; dialogHeight:200px;help:0;status:0;resizeable:1");
if (arr != null)
{
var imagestring = "<img src=uploads/"+ arr[filename] + " width="+arr[width]+" height="+arr[height]+">";
range.pasteHTML(imagestring);
}
else HtmlEdit.focus();
}
//-->
</SCRIPT>