Answer the question
In order to leave comments, you need to log in
How to fix the script so that it works in Firefox?
FF swears:
TypeError: e is undefined
function move(e,b,r) //для получения координат мышки
{
e = e || window.event
if ( e.pageX == null
&& e.clientX != null
)
{
var html = document.documentElement
var body = document.body
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0)
e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0)
}
//устанавливаем тултип на уровне мышки
jQuery('.tool').css('left',e.pageX + 15 + r + 'px');
jQuery('.tool').css('top',e.pageY + 15 - b + 'px');
}
Answer the question
In order to leave comments, you need to log in
Everything turned out to be simple, it was necessary to pass the event through jQuery.
As a result, this is what I got:
jQuery(document).ready(function(){
jQuery('map area').mouseover(function(e){
data = maparray[jQuery(this).index()];
jQuery('<div class="tool"></div>').appendTo('body').html(data);
//console.log(e.clientX, e.clientY, e.pageX, e.pageY);
jQuery('.tool').css('left',e.pageX + 15 + 'px');
jQuery('.tool').css('top',e.pageY + 15 + 'px');
});
});
You should pass event as the first parameter to the move function (and you, it seems to me, pass 0 there). In chrome, it works because e is replaced by window.event, while in FF there is no such value (The example you provided in the link also throws a TypeError: e is undefined on hover).
Looked at the example code. I suggest that the over function also add the e parameter and then transfer it to the move function. something like this:
function over(e,tip) //функция при наведении
{
//обрабатываем массив с данными
data_color = '';
data = maparray[tip-1];
data = data.split(';');
name = data[0]
square = data[1]
desc = data[2]
//добавляем тултип
$('').appendTo('body').html(name+' '+square+'кв.м.'+desc);
move(e,0,0);
}
$(document).ready(function(){
$('area').mouseover(function(e) {
over(e,$(this).index()+1);
});
});
jshint.com paste your code here and look for errors in the code, you simply miss ";"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question