135编辑器有个面得的服务,就是可以使用他们的编辑器,编辑后在自己网站获取到编辑的内容,对于发稿业务,有紧急需求的可以用一下
这个方法主要原理就是window对象里子父窗口通讯
function show135Editor() {
//注意这里一定要传一个callback
var url = 'http://www.135editor.com/beautify_editor?callback=1';
// window.open(url,'new_window','height='+(window.screen.availHeight - 60) +',width='+(window.screen.availWidth - 60)+';help=no,resizable=no,status=no,scroll=yes');
var myEditor = window.open(
url,
'new_window',
'height=' +
(window.screen.availHeight - 60) +
',width=' +
(window.screen.availWidth - 60) +
';help=no,resizable=no,status=no,scroll=yes',
);
setTimeout(function () {
//这里可以把自己编辑器的内容获取之后传给135编辑器,我这里使用编辑器是tinymce
var content = tinymce.activeEditor.getContent();
content = content.replace(/<review style=".*?">(.*?)<\/review>/gi, '$1');
content = content.replace(/·/gi, '·');
content = content.replace(/&middot;/gi, '·');
content = content.replace(/“/gi, '“');
content = content.replace(/&ldquo;/gi, '“');
content = content.replace(/”/gi, '”');
content = content.replace(/&rdquo;/gi, '”');
content = content.replace(/‘/gi, '‘');
content = content.replace(/&lsquo;/gi, '‘');
content = content.replace(/’/gi, '’');
content = content.replace(/&rsquo;/gi, '’');
myEditor.postMessage(content, '*');
}, 3000);
window.addEventListener(
'message',
function (event) {
//获取135编辑回跳的数据
var htmldata = event.data;
},
false,
);
}