Call Google Adsense advertisement cnblogs using JS files

Source: Internet
Author: User

InsertGoogleAdsense adsSource codeDirectly embed the topic template page. In factGoogleAdsense supports and allows the use of JSFileCall. Of course, the premise is not to modify it for any reason.Code, Or manually affects the positioning of the advertisement. This will be caused by a violation of the Plan PolicyGoogleClick your account.

The following uses the 468x60 classic AD Size code as an example to describe JSFileThe method to call.

The code for getting an advertisement unit is as follows:

 
<SCRIPT type = "text/JavaScript"> <! -- Google_ad_client = "publisher ID";/* 468x60, created in XX-xx */google_ad_slot = "xxxxxxxxxx"; google_ad_width = 468; google_ad_height = 60; // --> </SCRIPT> <SCRIPT type = "text/JavaScript" src = "http://pagead2.googlesyndication.com/pagead/show_ads.js"> </SCRIPT>

After getting this code, you need to convert it to the JS form:

Document. writeln ("<SCRIPT type = \" text \/JavaScript \ "> <! -- "); Document. writeln ("google_ad_client = \" publisher ID \ ";"); document. writeln ("\/* 468x60, created in XX-xx * \/"); document. writeln ("google_ad_slot = \" xxxxxxxxxx \ ";"); document. writeln ("google_ad_width = 468;"); document. writeln ("google_ad_height = 60;"); document. writeln ("\/-->"); document. writeln ("<\/SCRIPT>"); document. writeln ("<SCRIPT type = \" text \/JavaScript \ ""); document. writeln ("src = \" http: \// pagead2.googlesyndication.com \/pagead \/show_ads.js \ ">"); document. writeln ("<\/SCRIPT> ")

In view of the trouble to manually change, it is recommended to use online HTML to JS tools, such as: http://www.book560.com/Other/jstohtm.htm

Save the converted code as JSFileThe call method is as follows:

 
<Script language = "JavaScript" src = "ggad_468x60.js" type = "text/JavaScript"> </SCRIPT>

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.