因为业务需要,我把原有的给文字加超级链接的js方法改写了
原方法为:
click : function(id) {
KE.util.selection(id);
this.dialog = new KE.dialog({
id : id,
cmd : 'link',
file : 'link/link.html?id=' + id + '&ver=' + KE.version,
width : 400,
height : 100,
loadingMode : true,
title : KE.lang['link'],
yesButton : KE.lang['yes'],
noButton : KE.lang['no']
});
this.dialog.show();
},
因为公司有固定的格式,所以弹出层要改动,我就改写成了
click : function(id) {
KE.util.selection(id);
parent.window.$openWin("/common/editorUrl.html",580,200,"超链接",false,{onHidden:function(){}})
}
弹出页面里加了:
<script type="text/javascript">
var KE = parent.KE;
location.href.match(/\?id=([\w-]+)/i);
var id = RegExp.$1;
KE.event.ready(function() {
var hyperLink = KE.$('hyperLink', document);
var linkType = KE.$('linkType', document);
var linkNode = KE.plugin['link'].getSelectedNode(id);
if (linkNode) {
var tempDiv = KE.$$('div', KE.g[id].iframeDoc);
tempDiv.appendChild(linkNode.cloneNode(false));
var linkHtml = tempDiv.innerHTML;
var src = linkNode.href;
if (linkHtml.match(/kesrc="([^"]+)"/i)) src = RegExp.$1;
var target = linkNode.target;
hyperLink.value = KE.util.unescape(src);
linkType.value = target == '_blank' ? target : '';
var range = KE.g[id].keRange;
range.selectTextNode(linkNode);
KE.g[id].keSel.addRange(range);
}
KE.util.hideLoadingPage(id);
}, window, document);
</script>
杯具发生了,弹出页面报错,说KE对象为空,哪位高人帮帮忙!!