0
This function is perfect on Chrome but does not work on firefox. the error is that in firefox it returns me in the console that "Event is not defined" but in chorme ta ok. The variables that are not in the function are global. (I don’t use jquery and I don’t want to use)
Calling on the Onmousedown:
function move_janela_inicia(div_barra_id)
{
<!--pega o tamanho do body principal que esta na index-->
elemento_body = window.parent.document.getElementById('corpo_main');
<!--pega o retangulo do body-->
boxDoElemento = elemento_body.getBoundingClientRect();
<!--pega a camada que vai se mover efetivamente, a barra filha já veio no parãmetro e assim sei quem é a pai-->
elemento_move=document.getElementById(window.parent.document.getElementById(div_barra_id).parentNode.id);
maximo_top=elemento_body.offsetHeight-elemento_move.offsetHeight;
maximo_left=elemento_body.offsetWidth-elemento_move.offsetWidth;
mover=1;
document.getElementById(div_barra_id).addEventListener("mouseout", function() {
move_janela_mouse();
}, false);
}
Call in the function above
function move_janela_mouse()
{
if (mover==1)
{
<!--pega o quanto rolou-->
var rolamentoX = elemento_body.scrollLeft;
var rolamentoY = elemento_body.scrollTop;
var xmouse=event.clientX;
var ymouse=event.clientY;
var px=((xmouse-boxDoElemento.left + rolamentoX)-(elemento_move.clientWidth/2));
var py=ymouse-boxDoElemento.top + rolamentoY;
<!--mantem a janela dentro dos limites-->
if (py<0) py=0;
if (py>(maximo_top)) py=maximo_top-50;
if (px<0) px=0;
if (px>maximo_left) px=maximo_left;
elemento_move.style.left=px;
elemento_move.style.top=py;
mover=0;
}
}
How do you associate the event with that function? The problem is in that part, not in the function code itself. Or at least not only.
– bfavaretto
That is my question, if I put Event as a parameter in the function, what should I pass to this parameter? An event? Which and why?
– Luis Miguel
It depends on how you associate the event... There is a way to do it that does not need to pass anything, the passage is automatic. It is the most recommended way, with
addEventListener
.– bfavaretto
I put the whole code, it’s in one. js so that I can call with any layer that I want, just pass the div that is in the role of Window Window and works perfect on Chrome, but not firefox.
– Luis Miguel