转载自网址:
http://www.vephp.com/jiaocheng/125.html
问题:
百度umeditor在线编辑器,
插入超级链接,
查看源码后,
变成http://undefined
问题排查:
问题可以锁定在源码切换功能出现问题。
这个功能在umeditor.js第6907行左右
me.commands['source']
其中的 me.filterOutputRule(root); // 这里让超链接变成 http://undefined ,通过跟踪,我们把问题代码锁定在
a.setAttr('href', _href);
其中的 _href出问题了,它获取方式var _href = a.getAttr('_href');这个_href的属性不存在,因此获得取undefined值。如图:
因此,解决办法:
把var _href = a.getAttr('_href');改成var _href = a.getAttr('href');
同时加一个过滤保险:if(_href!='http://undefined') a.setAttr('href', _href);
如图:
对于umeditor.min.js,查找 ftp|https?|\/|file 可以快速定位到问题代码处,并改动如下:
搞定,刷新重新测试,问题解决了。