Kindeditor一般调用方式
var editor;
KindEditor.ready(function(K) {
editor = K.create('textarea[name="控件Name"]', {
uploadJson: '
http://img.chinafloor.cn:58433/upload/ContentUpload/Product',//Json的回调服务器
allowFileManager : false,
afterCreate: function () {
var self = this;
K.ctrl(document, 13, function () {
debugger;
self.sync();
});
K.ctrl(self.edit.doc, 13, function () {
debugger;
self.sync();
});
}
});
});
回调页面(
http://img.chinafloor.cn:58433/upload/ContentUpload/Product)输出内容
<script type=\"text/javascript\">document.domain=\"与你调用页面的域(www.51tbd.com)名统一\"</script>
<pre>{\"error\":0,\"url\":\"图片服务器图片地址\"}</pre>//正确的,
<pre>{\"error\":1\"message\":\"错误信息\"}</pre>//错误的
例:
<pre>{\"error\":0,\"url\":\"http://img.chinafloor.cn:58433/up/product/2013_03_07/product_6972ed0.jpg
\"}</pre>
kindeditor.js
修改部分
function _getBasePath()
{
var els = document.getElementsByTagName('script'), src;
for (var i = 0, len = els.length; i < len; i++) {
src = els[i].src || '';
if (/kindeditor[\w\-\.]*\.js/.test(src)) {
return src.substring(0, src.lastIndexOf('/') + 1);
}
}
return '';
}
为
function _getBasePath() {
return "http://img1.chuguicdn.com:58433/res/p/js/kindeditor/";//编辑器存放路径
}
至此就实现了跨域上传