This article mainly introduces a simple example of js mouse moving and displaying images. If you need a friend, please refer to it and hope to help you. 1. js Code
The Code is as follows:
// ************ Default setting definition .*********************
TPopWait = 50; // The prompt is displayed after the tWait Hao seconds.
TPopShow = 5000; // display the tShow Hao seconds before closing the prompt
ShowPopStep = 20;
PopOpacity = 99;
// *************** Internal variable definition *****************
SPop = null;
CurShow = null;
TFadeOut = null;
TFadeIn = null;
TFadeWaiting = null;
Document. write (" ");
Document. write ("
");
Function showPopupText (){
Var o = event. srcElement;
MouseX = event. x;
MouseY = event. y;
If (o. alt! = Null & o. alt! = "") {O. dypop = o. alt; o. alt = ""};
If (o. title! = Null & o. title! = "") {O. dypop = o. title; o. title = ""};
If (o. dypop! = SPop ){
SPop = o. dypop;
ClearTimeout (curShow );
ClearTimeout (tFadeOut );
ClearTimeout (tFadeIn );
ClearTimeout (tFadeWaiting );
If (sPop = null | sPop = ""){
DypopLayer. innerHTML = "";
DypopLayer. style. filter = "Alpha ()";
DypopLayer. filters. Alpha. opacity = 0;
}
Else {
If (o. dyclass! = Null) popStyle = o. dyclass
Else popStyle = "cPopText ";
CurShow = setTimeout ("showIt ()", tPopWait );
}
}
}
Function showIt (){
DypopLayer. className = popStyle;
DypopLayer. innerHTML = sPop;
PopWidth = dypopLayer. clientWidth;
PopHeight = dypopLayer. clientHeight;
If (MouseX + 12 + popWidth> document. body. clientWidth) popLeftAdjust =-popWidth-24
Else popLeftAdjust = 0;
If (MouseY + 12 + popHeight> document. body. clientHeight) popTopAdjust =-popHeight-24
Else popTopAdjust = 0;
DypopLayer. style. left = MouseX + 12 + document. body. scrollLeft + popLeftAdjust;
DypopLayer. style. top = MouseY + 12 + document. body. scrollTop + popTopAdjust;
DypopLayer. style. filter = "Alpha (Opacity = 0 )";
FadeOut ();
}
Function fadeOut (){
If (dypopLayer. filters. Alpha. opacity DypopLayer. filters. Alpha. opacity + = showPopStep;
TFadeOut = setTimeout ("fadeOut ()", 1 );
}
Else {
DypopLayer. filters. Alpha. opacity = popOpacity;
TFadeWaiting = setTimeout ("fadeIn ()", tPopShow );
}
}
Function fadeIn (){
If (dypopLayer. filters. Alpha. opacity> 0 ){
DypopLayer. filters. Alpha. opacity-= 1;
TFadeIn = setTimeout ("fadeIn ()", 1 );
}
}
Document. onmouseover = showPopupText;
Ii. html code contains js Code. Example
"> Big"> small