Yesterday, I made some special effects on floating web pages for IT companies in the same industry!

Source: Internet
Author: User
Html Code As follows: Code
< Div ID = Img1 Style = " Z-INDEX: 100; left: 2px; width: 200px; position: absolute; top: 43px; Height: 100px;
Visibility: visible; " > <A href = " HTTP: // Www.sutt56.com/index.asp "target =" _ blank "> </a> </ div>
< Script SRC = " JS/JS. js " > </ Script >

The javascript code is as follows: Code
VaR xpos = 300 ;
VaR ypos =   200 ;
VaR step =   1 ;
VaR Delay =   20 ;
VaR height =   0 ;
VaR hoffset =   0 ;
VaR woffset =   0 ;
VaR yon =   0 ;
VaR Xon =   0 ;
VaR pause =   True ;
VaR interval;
Img1.style. Top = Ypos;
Function changepos ()
{
Width = Document. Body. clientwidth;
Height = Document. Body. clientheight;
Hoffset = Img1.offsetheight;
Woffset = Img1.offsetwidth;
Img1.style. Left = Xpos + Document. Body. scrollleft;
Img1.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 ()
{
Img1.visibility =   " Visible " ;
Interval = Setinterval ( ' Changepos () ' , Delay );
}
Function pause_resume ()
{
If (Pause)
{
Clearinterval (interval );
Pause =   False ;}
Else  
{
Interval = Setinterval ( ' Changepos () ' , Delay );
Pause =   True ;
}
}
Start ();

Save this file as Js. js under the JS directory

Image Source:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.