百度umeditor在线编辑器插入链接查看源码后变成http://undefined

转载自网址:
http://www.vephp.com/jiaocheng/125.html

问题:
百度umeditor在线编辑器,
插入超级链接,
查看源码后,
变成http://undefined

百度umeditor在线编辑器插入链接查看源码后变成http://undefined

百度umeditor在线编辑器插入链接查看源码后变成http://undefined

百度umeditor在线编辑器插入链接查看源码后变成http://undefined

百度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在线编辑器插入链接查看源码后变成http://undefined

对于umeditor.min.js,查找 ftp|https?|\/|file 可以快速定位到问题代码处,并改动如下:

百度umeditor在线编辑器插入链接查看源码后变成http://undefined

搞定,刷新重新测试,问题解决了。

转载自网址:
http://www.vephp.com/jiaocheng/125.html

猜你喜欢

转载自blog.51cto.com/phpervip/2133267