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 + ' 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" > </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" > </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)