Salve, io ho questo codice javascript per gestire un'etichetta a comparsa:
codice:
<SCRIPT type="text/javascript">
var IE = document.all?true:false;
var Coordinate = new Object;
if (!IE)
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;
function cambia(layer,visibilita,codice)
{
if(document.getElementById(layer).style.visibility == 'hidden' && visibilita == 'visible')
{
document.getElementById(layer).style.left = Coordinate[0];
document.getElementById(layer).style.top = Coordinate[1];
if(codice != "")
document.getElementById(layer).innerHTML = codice;
document.getElementById(layer).style.visibility = 'visible';
}
else if(document.getElementById(layer).style.visibility == 'visible' && visibilita == 'hidden')
{
document.getElementById(layer).style.visibility = 'hidden';
document.getElementById(layer).style.left = 0;
document.getElementById(layer).style.top = 0;
}
}
function getMouseXY(e)
{
if (IE)
{ // grab the x-y pos.s if browser is IE
Coordinate[0] = event.clientX + document.body.scrollLeft;
Coordinate[1] = event.clientY + document.body.scrollTop;
}
else
{ // grab the x-y pos.s if browser is NS
Coordinate[0] = e.pageX;
Coordinate[1] = e.pageY;
}
if (Coordinate[0] < 0)
Coordinate[0] = 0;
if (Coordinate[1] < 0)
Coordinate[1] = 0;
}
</SCRIPT>
L'etichetta funziona bene, solo che sia firefox che browser mi dicono che:
codice:
Error: document.getElementById(layer) has no properties
Come posso risolvere il problema?