Home  >  Article  >  Web Front-end  >  A simple way to implement floating ads on web pages using JavaScript_javascript skills

A simple way to implement floating ads on web pages using JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:32:241883browse

Walking around the Internet, you will find that the Internet is not only an ocean of information, but also an ocean of advertisements. In addition to ordinary Gif Banner and Flash, floating ads are also one of the more popular forms of advertising on the Internet nowadays. When you drag the browser's scroll bar, this kind of floating advertisement on the page can move with the screen. Although this effect has considerable practical value for advertising display, for people browsing your webpage, this is something that both hinders reading and affects reading interest, so it must not be abused. However, if you use it wisely, it can be extremely useful.


It is not difficult to create the effect of a floating advertisement. If you have a basic knowledge of JS, you can write one yourself. If you are too lazy to write, download a special effects tool online and paste the code as prompted. . However, if you want to really understand how it is made, you need to master some JS knowledge. Here I will introduce to you a simple floating advertisement method.

The following code can be placed between , during which I added some comments (i.e. the text after "//" and "" text between).

Copy code The code is as follows: