Roaming between the network, you will find that the Internet is not only the ocean of information, but also the ocean of advertising. In addition to ordinary GIF Banner, Flash, floating advertisements are also one of the popular advertising forms. When you drag the browser scroll bar, this advertisement on the page can move with the screen. Although this effect has considerable practical value for advertising demonstrations, this is something hinder reading and affecting reading interest, so it must not be abused. However, if you can make good use, it will play a great role.
It is not difficult to make a floating advertisement. If you have a JavaScript foundation you can write one, if you are too lazy to write, download a special effect tool online, press the prompt and paste the code is OK. However, if you want to really understand how it is made, you need to master some JavaScript knowledge. Here you will introduce you to a simple floating advertising approach.
The following code can be placed between
body>, and I have added some comments (ie "//" text and " ".INITAD (); // Load the page, call the function initAd ()
Script>
Function initad () {
Document.All.adlayer.style.postop = -200;
// Set the ONLOAD event inspector, the ad layer is positioned relative to the fixed Y direction.
Document.all.adlayer.style.visibility = 'visible' // Setting layer is visible
MoveLayer ('adlayer'); // Call function MoveLayer ()
}
Function movelayer (layername) {
VAR x = 30; // Floating advertising layer is fixed to the X direction position of the browser
VAR Y = 10; // Floating advertising layer is fixed to the Y direction position of the browser
VAR DIFF = (Document.Body.Scrolltop Y - Document.All.adlayer.style.postop) *. 40;
VAR Y = Document.body.scrolltop Y - DIFF;
eVal ("Document.all." LayerName ".Style.Postop = Y");
EVAL ("Document.all." LayerName ".Style.posleft = x"); // Mobile Advertising
SetTimeout ("'Adlayer');", 20); // Set 20 milliseconds after calling the function moveer ()
}
// ->
script>
The Adlayer in MoveLayer () also modifies it), including a link with a link ->
div>
Here, you can set the value of x, y to set the position of the fixed layer, change Settimeout; "," 10) value to call the time interval for calling MoveLayer (). It is also important to note that the image used is the best to transparent background, so that the background color of the picture is not covered with the back.
Remember, you should use floating advertisements to consider the use of special effects, don't take into account your feelings, you can't abuse.