JavaScript code is used to implement a movable icon floating on the webpage. When the mouse is placed on the webpage, the icon does not move. After the icon is removed, it begins to move again.
The javascript code is as follows:
<Script language = 'javascript '>
VaR xpos = 0;
VaR ypos = 0;
VaR step = 1;
VaR delay = 10;
VaR Height = 0;
VaR hoffset = 0;
VaR woffset = 0;
VaR yon = 0;
VaR Xon = 0;
VaR Xon = 0;
VaR interval;
VaR IMG = Document. getelementbyid ('img ');
IMG. style. Top = 0;
Function changepos ()
...{
Width = Document. Body. clientwidth;
Height = Document. Body. clientheight;
Hoffset = IMG. offsetheight;
Woffset = IMG. offsetwidth;
IMG. style. Left = xpos + document. Body. scrollleft;
IMG. style. Top = ypos + document. Body. scrolltop;
If (yon )...{
Ypos = ypos + step;
} Else ...{
Ypos = ypos-step;
}
If (ypos <0 )...{
Yon = 1;
Ypos = 0;
}
If (ypos> = (height-hoffset ))...{
Yon = 0;
Ypos = (height-hoffset );
}
If (Xon )...{
Xpos = xpos + step;
}
Else ...{
Xpos = xpos-step;
}
If (xpos <0 )...{
Xon = 1;
Xpos = 0;
}
If (xpos> = (width-woffset ))...{
Xon = 0;
Xpos = (width-woffset );
}
}
Function start ()...{
IMG. Visibility = 'visable ';
Interval = setinterval ('changepos () ', delay );
}
Function mystop ()
...{
Clearinterval (interval)
}
Start ()
</SCRIPT>
The Code is as follows:
<! -- Wide code for floating flash icons -->
<Span id = 'img 'style = 'position: absolute; 'onmouseover = 'mystop ()' onmouseout = 'start () '>
<Object classid = 'clsid: D27CDB6E-AE6D-11cf-96B8-444553540000 'codebase = 'HTTP: // download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab?version=6,0'
Width = '20180101' Height = '20180101'>
<Param name = 'movie 'value = 'HTTP: // www.myhome.com.cn/swf/sample.swf'>
<Param name = 'quality' value = 'high'>
<Param name = "wmode" value = "Transparent">
<! -- The code here can make the flash background transparent -->
<Embed src = 'HTTP: // www.myhome.com.cn/swf/sample.swf' Quality = 'high' pluginspage = 'HTTP: // www.macromedia.com/go/getflashplayer'
Type = 'application/X-Shockwave-flash' width = '000000' Height = '000000'> </embed>
</Object>
</Span>
Principle: Call the flash component of Macromedia and run the specified SWF file in the span (<Param name = 'move' value = 'HTTP: // www.myhome.com.cn/swf/sample.swf'> ), javaScript scripts are used to control span motion.