JavaScript custom Location Insert Baidu affiliate ADS

Source: Internet
Author: User
Tags html page

Baidu Advertising Call method has direct JS code to release the source so if it is an HTML page to modify the trouble, the other is directly call JS external ads, this if a page more than 10 code flow a large number of page thread increase lead to environmental overload, the following methods have two, the following one to see.

WordPress How to customize the position in the article to insert Baidu Alliance ads? For example, set a tag bit, insert the mark bit, this position will display ads. WordPress can use the Add_shortcode function to set a short label, the implementation of the article page custom position inserted Baidu Alliance ads.

Directly on the code:

Php

code as follows  

//Baidu advertising Shortcode
function Bdad ($attrs) {
if (= = $at trs[' size '] {
$bdad = <<<bdad
< div style= "float:right;"
< script type= "Text/javascript"
/*300*250 created in 2014-08-23*/
var cpro_id = "u1674017";
</SCR Ipt>
< script src= "Http://cpro.baidustatic.com/cpro/ui/c.js" type= "Text/javascript" ></script>
</div>
Bdad;
} else{
$bdad = <<<bdad
< div style= "width:580px;margin:0 auto;"
< script type= "Text/javascript"
/*580*90 created in 2014-08-13*/
var cpro_id = "u1657518";
</SCRI Pt>
< script src= "Http://cpro.baidustatic.com/cpro/ui/c.js" type= "Text/javascript" ></script>
</div>
Bdad;
}
if (Is_single ()) {
return $bdad;
}
return ";
}
Add_shortcode (' Bdad ', ' Bdad ');

Note The last code: Add_shortcode, the first argument is the tag bit name, and the second is the function name that is executed. After adding the above code in the subject functions.php, enter {Bdad} or {Bdad size= "300″}" at any custom position in the article (note that this {} is represented by [], which is replaced with this tag).

From the above set reminds me of the recent improvement of a paragraph JS load Baidu Advertising code example

The code is as follows

function DW (a) {
Document.writeln (a)
}
function Bdjs (d, b) {
var c = ' <script src= ' http://cpro.baidustatic.com/cpro/ui/c.js ' type= ' text/javascript ' ></script> ';
var a = ' <script src= ' http://cpro.baidustatic.com/cpro/ui/f.js ' type= ' text/javascript ' ></script> ';
if (b = = "C") {
DW (' <script type= "Text/javascript" >var cpro_id = "' + D + '";</script> ' + C)
} else {
DW (' <script type= "Text/javascript" >var cpro_id = "' + D + '";</script> ' + a)
}
}

function dy (b)
{
if (b = = "BCR") {
Bdjs ("u91397", "C")
}
if (b = = "baidu580") {
Bdjs ("u776243", "C")
}
if (b = = "Bdtxt") {
Bdjs ("u1589648", "C")
}
}

Directly when HTML calls ads

code as follows  
<script>dy (' BCR ') </script> This is the specified location call specified code, very simple.
Dy (b)
Related Article

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.