Javascript random ad code (image AD) _ ad code

Source: Internet
Author: User
Some random image advertisements, excluding flash advertisements, can be used for random display of advertisements.

<Script LANGUAGE = "Javascript"> <! -- // Banner rotator var tag1 = new Array (); var urlArray = new Array (); //************************************** ****************** // ****** START 6-6 ***** // urlArray [urlArray. length] =" http://s.jb51.net "; Tag1 [tag1.length] =" http://img.jb51.net/imgby/server.gif "; UrlArray [urlArray. length] =" http://www.jb51.net "; Tag1 [tag1.length] =" http://www.jb51.net /Images/logo.gif "; // ***** END 6-25 ***** // var adsAry_length = tag1.length; var now = new Date (); // MOD 20090522var sec = now. getSeconds (); // MOD 20090522 var ad = sec % adsAry_length; var sec = now. getTime (); var ad = rand (adsAry_length) var url = urlArray [ad-1]; var banner = tag1 [ad-1]; // DEL alert ("urlArray [" + (ad-1) + "] =" + urlArray [ad-1]) // DEL 20090522 if (ad <= tag1.length) {// DEL 20090522 url = urlArray [ad]; // DEL 20090522 banner = tag1 [ad]; // DEL 20090522} // DEL 20090522 document. write ('<center>'); document. writeln (''); document. writeln (''); // DEL 20090522 document. write ('<\ center> '); //************************************** * ************* // rnd () //************************************** * ************/function rnd () {var ia = 9301; var ic = 49297; var im = 233280; sec = (sec * ia + ic) % im; return sec/(im * 1.0 );}; //************************************** * ************* // rand (number) //************************************** * ************/function rand (number) {return Math. ceil (rnd () * number) ;}; // --> script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]


There is a good random function code in it, but it is not clear. You can reply to a friend you know.

The Code is as follows:


Function rnd (){
Var ia = 9301;
Var ic = 49297;
Var im = 233280;
Sec = (sec * ia + ic) % im;
Return sec/(im * 1.0 );
};

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.