Copy codeThe Code is as follows:
<Script>
Function GetAbsPosition (obj)
{
Var curleft = 0, curtop = 0;
Do {
Curleft + = obj. offsetLeft;
Curtop + = obj. offsetTop;
} While (obj = obj. offsetParent );
Return [curleft, curtop];
}
Function ShowFloatingImage (image, width, height)
{
Var id = "trailimageid ";
Var newdiv = document. getElementById (id );
If (newdiv = null)
{
Newdiv = document. createElement ('div ');
Newdiv. setAttribute ('id', id );
Newdiv. setAttribute ('onmouseout', "HideElement ('" + id + "');");
Document. body. appendChild (newdiv );
}
Newdiv. innerHTML = ' ';
Var absPos = GetAbsPosition (image );
Newdiv. style. position = "absolute ";
Newdiv. style. posLeft = absPos [0]-width/2;
Newdiv. style. posTop = absPos [1]-height/2;
Newdiv. style. display = "block ";
}
Function HideElement (id)
{
Var elem = document. getElementById (id );
Elem. style. display = "none ";
}
</Script>
Example:
Copy codeThe Code is as follows:
<Body>
</Body>
The tested event is not well handled. As a result, you cannot move the cursor back to the original position.