The js obtained from Netease calls the ad display file (random probability)

Source: Internet
Author: User

Call the advertisement display file from js pulled by Netease
Only a few lines of code below can randomly display flash and gif ads, not bad Copy codeCode: function column02 (imgSource, url, chance, type ){
This. imgSource = imgSource;
This. url = url;
This. chance = chance;
This. type = type;
}
Function dispColumn02 (){
With (this)
Switch (type ){
Case "img ":
Document. write ("<a href =" + url + "target = _ blank> </A> ");
Break;
Case "html ":
Document. write ("<iframe width = 480 HEIGHT = 250 MARGINWIDTH = 0 MARGINHEIGHT = 0 HSPACE = 0 VSPACE = 0 FRAMEBORDER = 0 SCROLLING = no BORDERCOLOR = #000000 SRC =" + imgSource +"> </iframe> ");
Break;
Case "flash ":
Document. write ("<embed src =" + imgSource + "quality = high width = 480 height = 250 type = application/x-shockwave-flash pluginspage = http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version = ShockwaveFlash> </embed> ");
Break;
Default:
Document. write ("");
}
}
Column02.prototype. dispColumn02 = dispColumn02;
Columns02 = new Array ();
// Flash, html, and img represent three different ad Modes
// The number of 200 is the probability of occurrence.
Columns02 [0] = new column02 ("http://smsimg.163.com/honey/honey_ad.swf", "", 200, "flash"); // ad
Columns02 [1] = new column02 ("http://smsimg.163.com/honey/honey_photo.swf", "", 800, "flash"); // upload images for rent-free monthly
Columns02 [2] = new column02 ("http://smsimg.163.com/honey/honey_gold.swf", "", 800, "flash"); // login to send gold coins
// Columns02 [] = new column02 ("f", "", 100, ""); // (20030422 ~ 20030722)
Sum_of_all_chances = 0;
For (I = 0; I <columns02.length; I ++ ){
Sum_of_all_chances + = columns02 [I]. chance;
}
Function randomColumn02 (){
Chance_limit = 0;
Randomly_selected_chance = Math. round (sum_of_all_chances-1) * Math. random () + 1;
For (I = 0; I <columns02.length; I ++ ){
Chance_limit + = columns02 [I]. chance;
If (randomly_selected_chance <= chance_limit ){
Columns02 [I]. dispColumn02 ();
Break;
}
}
}
This_column02 = randomColumn02 ();

The larger the chance, the higher the chance of displaying the code.
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

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.