Insert a Google Adsense advertisement into a webpage.Source codeDirectly embed the topic template page. In fact, Google Adsense supports and allows JS file calls. Of course, the premise is not to modify it for any reason.Code, Or manually affects the positioning of the advertisement. This will be compromised by Google accounts for violation of the Plan policy.
Taking the classic AD Size code of 468x60 as an example, Mango describes how to call JS files.
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.hao123.com/haoserver/jstohtm.htm
Save the converted code as a JS file by calling the following method:
<Script language = "JavaScript" src = "ggad_468x60.js" type = "text/JavaScript"> </SCRIPT>
Of course, for powerful WordPressProgramYou can use various AdSense advertising management plug-ins to manage code. In addition, this method is not limited to AdSense, and is also applicable to other advertisers.