Как победить всплывание title в IE?
Вложений: 1
Всем привет.
Хотел приложить скрин, но не судьба :) Вот код
toolTips: function(){
$("body").delegate(".toolTips", "mouseover", function(e){
var text = $(this).attr("title");
$(this).removeAttr("title");
var hht = $('#toolTipBlock').height();
var wth = $('#toolTipBlock').width();
var dhht = $(document.body).height()-2;
var dwth = $(document.body).width()-2;
var idx = 10;
$(document).bind('mousemove', function(e){
var pX, pY;
if((e.pageX+wth)>(dwth-idx)){
pX = e.pageX - wth - idx;
}else{
pX = e.pageX+idx;
}
if((e.pageY+hht)>(dhht-idx)){
pY = e.pageY - hht - idx;
}else{
pY = e.pageY+idx;
}
$('#toolTipBlock').css({
left : pX+'px',
top : pY+'px'
})
});
$('#toolTipBlock').text(text).show();
return false;
});
$("body").delegate(".toolTips", "mouseout", function(e){
$(this).attr("title", $('#toolTipBlock').text());
$(document).unbind('mousemove');
$('#toolTipBlock').hide();
return false;
});
}
Во всех браузерах нативные title не всплывают, в ИЕ - всплывают и мои, и нативные поверх. Как подавить? |
Решение подсказали други с Демиарта:
Создаём файл hide-title.htc :
<public:component>
<public:attach event="onmouseover" onevent="hideTitle();" />
<script>
function hideTitle() {
element.setAttribute("data-title", element.title);
element.setAttribute("title", "");
}
</script>
</public:component>
Подключаем его в документ
.toolTips { behavior:url(hide-title.htc); }
И чуть переделываем скрипт в начале:
if($.browser.msie){
var _key = "data-title";
}else{
var _key = "title";
}
if(!$(this).data("title")){
$(this).data("title", this.getAttribute(_key));
this.removeAttribute(_key);
}
var text = $(this).data("title");
//...
Не забываем так же о заголовке файла - если хак не работает, добавляем htaccess: AddType text/x-component .htc |
| Часовой пояс GMT +3, время: 21:51. |