2 asia1987 asia1987 于 2013.06.05 16:12 提问

CKEDITOR模态窗口提交表单时能不弹出新窗口吗?

按照http://www.iteye.com/topic/749437 该文章内容实现ckeditor在jsp下增加图片上传功能中遇到上传图片的模态窗口在表单提交时,总是弹出新窗口,我在

中间添加了。还是不管用,那位大侠能帮助解决一下?
以下是代码
修改控件代码:
`
function addUploadButton(editor){
CKEDITOR.on('dialogDefinition', function( ev ){
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if ( dialogName == 'image' ){
var infoTab = dialogDefinition.getContents( 'info' );
infoTab.add({
type : 'button',
id : 'upload_image',
align : 'left',
label : '上传',
onClick : function( evt ){
var thisDialog = this.getDialog();
var txtUrlObj = thisDialog.getContentElement('info', 'txtUrl');
var txtUrlId = txtUrlObj.getInputElement().$.id;
addUploadImage(txtUrlId);
}
}, 'browse'); //place front of the browser button
}
});
}

function addUploadImage(theURLElementId){
var uploadUrl = "uploadimage.jsp"; //这是我自己的处理文件/图片上传的页面URL
var imgUrl = window.showModalDialog(uploadUrl,new Object(),'dialogHeight=70px;dialogWidth=400px;resizable:no;status:no;scroll:auto;');
//在upload结束后通过js代码window.returnValue=...可以将图片url返回给imgUrl变量。
var urlObj = document.getElementById(theURLElementId);
urlObj.value = imgUrl;
urlObj.fireEvent("onchange"); //触发url文本框的onchange事件,以便预览图片
} `

上传页面:
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/include/global.jsp"%>




上传文件
<%
String path = (String)request.getAttribute("path");

%> window.name = "_self"; function update_onClick(){ var ownerFile=document.getElementById('uploadFile').value; document.getElementById("_pagePath").value=ownerFile; if(ownerFile==null || ownerFile==""){ alert("请选择上传的文件!"); return false; } form.action="<venus:base/>/UpLoadFileAction.do?cmd=upLoadImage"; form.target="_self"; form.submit(); }
上传文件
请选择上传的文件: " name="pagePath" id="_pagePath" />
var _pagePath = document.getElementById("_pagePath").value; if(null!=_pagePath && ""!=_pagePath){ window.returnValue=_pagePath; window.close(); }


Csdn user default icon
上传中...
上传图片
插入图片