Carousel Diagram:
The function is bound inside the body tag
3 images, 1.jpg 2.jpg 3.jpg using timed task execution to set picture properties Src uses a For loop to complete a 3-second replacement.
Timed pop-up ads:
Because the body tag is already bound to the function
So directly load the event function with window
The default display property for AD images is none
After 3 seconds, the display property of the ad image is set to block to form 3 seconds after the ad image is displayed.
Need to clean up the timer after popup
Then write a 3-second time hidden function, and finally to clean up the timing.
<script>functioninit () {//write a timed operation of the carousel graph displaySetInterval ("Changeimage ()", 3000); //set up timed actions to display ad imagesTime =setinterval ("Showad ()", 3000) } //writing function varI=0functionChangeimage () {i++; //get picture position and set src property valuedocument.getElementById ("Img1"). src= ". /img/"+i+". jpg "; if(i==3) {i=0; } } //2. Functions for displaying AD images functionShowad () {//3. Get the location of your ad image varAdele=document.getelementbyid ("Img2"); //4. Modify the attributes inside the ad image element to showadele.style.display= "Block"; //5. Clearly display the image of the timing operationclearinterval (time); //6. Set a timed action for a hidden picturetime1= setinterval ("Hiddenad ()", 3000); } //7. Functions for writing hidden AD images functionHiddenad () {//8. Get the ad image and set the display value of its Style property to Nonodocument.getElementById ("Img2"). style.display= "None"; Clearinterval (time1)}</script>
JavaScripts AD Carousel and timed pop-up and timed hide ads