Self-writing jQuery large pop-up window ad plugin (don't like to shoot)

Source: Internet
Author: User
Tags cbtn

Recently wrote to do the two projects have to do almost the same thing, pop an ad on the homepage. Originally wanted to find one on the internet, looked for a few, took the time but are not very satisfied, the hell, the pit dad ah ...

The last thought, simply do it yourself.

For the first time, look for some examples on the Internet.

The specific process is not wordy, many online, you can click the link below the article to read. Go directly to the code.

(function($) {$.fn.creatwin=function(options) {varDefaults ={disp:"",//Auto Eject, none when not automatically ejectAurl: "#",//AD Jump LinkPSRC: "",//Advertising Picturestout:0//Auto-off time, not auto-off when 0        }; varOptions =$.extend (defaults, options); vars = ' <span role= ' col ' style= ' color:red;font-weight:bolder ' > ' + options.tout + ' </span> '; varc = ' <div class= ' pg_title ' > ' + S + ' &nbsp; seconds after auto-close </div> '; vart = "; if(Options.tout = = 0)
t = ' <div role= ' "Win" style= "display: ' + options.disp + '" ><div class= "Ly_bgshadow" ></div><div class = "Pg_layer" ><div class= "cbtn" >&nbsp;</div><a href= "' + Options.aurl + '" ></a></div></div>"; Else
t = ' <div role= ' "Win" style= "display: ' + options.disp + '" ><div class= "Ly_bgshadow" ></div><div class = "Pg_layer" ><div class= "cbtn" >&nbsp;</div><a href= "' + Options.aurl + '" ></a> ' + C + ' </div></div> '; $( This). Append (t); Win= $( This). Find ("Div[role=win]") $ (document). On (' Click ', '. Cbtn ',function() {$ (win). FadeOut (500) }); AutoClose (Options.tout, Win)}varAutoClose =function(time, obj) {if(Time = = 0) {$ (obj). FadeOut (500); } Else{$ ($ (obj). Find ("Span[role=col]") [0]). Text (time); time--; SetTimeout (function() {AutoClose (time, obj)},1000); }}) (JQuery);

How to use:

Parameter 5 means 5 seconds off.

$ (' body '). Creatwin ({tout:5});

Over

The first time to write this thing, a little messy, after more learning and optimization!

Demo: Click to view Effects

Download: Click to download all

Study articles:

Http://www.cnblogs.com/cyStyle/archive/2013/05/18/jQuery%E6%8F%92%E4%BB%B6%E8%AF%A6%E7%BB%86%E5%BC%80%E5%8F%91.html

Http://www.cnblogs.com/playerlife/archive/2012/05/11/2495269.html

Self-writing jQuery large pop-up window ad plugin (don't like to shoot)

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.