JavaScript code for pop-up advertisement

Source: Internet
Author: User
This article uses the example code to share with you the javascript pop-up advertisement function. The code is easy to understand and can be used for reference, for more information, see this article. We will share with you the example code to use javascript to implement the pop-up advertisement function. The code is simple and easy to understand. It is of reference value.

If you don't talk much about it, paste the Code directly. The specific code is as follows:


Var I = 0; // The number of record times var timer; // timer id // set the pop-up advertisement onload = function () {// display the ad timer once every four seconds = setInterval (showAd, 4000);} // function showAd () {I ++; // increase the number of times displayed by 1 // if I is equal to 3, clear the timer set by setInterval if (I = 3) {clearInterval (timer);} // 1. get var pObj = document. getElementById ("ad"); // 2. Modify the advertisement style pObj. style. display = "block"; // after two seconds, hide setTimeout (hiddAd, 2000);} // hide the advertisement function hiddAd () {var pObj = document. getElementById ("ad"); pObj. style. display = "none ";}

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.