在使用HtmlArea的时候,发现htmlarea的工具栏的提示(其实也就是title了),经常不能很好的工作,鼠标移到工具栏的按钮上面,工具栏名称提示经常发生有时显示,有时不显示的问题。
这个问题,一直发生了很久。。。。,并且发现只有在按钮很边上的时候,title才会正常显示,一旦往按钮中心移动,itle就消失了。终于有一天,忍受不了了。。。
看了htmlarea.js源码,原来是表示按钮的div层设置了title属性,但是div内部的img对象没有设置title属性,明白了,只要给这个img对象也加上title属性就好了。
解决方案:
在htmlarea.js文件中查找createButton方法的定义,
js 代码
- // appends a new button to toolbar
- function createButton(txt) {
我们可以看到在这个方法内部有这么几句
js 代码
- el = document.createElement("div");
- el.title = btn[0];
这是给div设置title,
再往下找到
js 代码
- var img = document.createElement("img");
- img.src = btn[1];
- img.style.width = "18px";
- img.style.height = "18px";
上面这段代码就是创建img对象,并设置相应属性,只要在中间加一句话 img.title = btn[0]; 变成下面这样
js 代码
- var img = document.createElement("img");
- img.src = btn[1];
- img.title = btn[0];
- img.style.width = "18px";
- img.style.height = "18px";
ok~~大功告成!~