Although a lot of people give each article to add the method of painting advertising, but these so-called methods, can not really achieve the text around the advertising "painting" effect, only left to it or right alignment. Now to discuss this method can really achieve such as Sina, Sohu, such as painting in the picture advertising effect.
First of all, to say the wrong div+css method, I hope you will not be misled:
<div id= "outer" style= "float:left;" >
<div id= "inner" style= "float:left;margin:0;width:200px;height:200px;" ></div>
text content
</div>
The above can only count as the effect of the left alignment. There are a lot of forms or iframe to implement, and nothing more.
So, how can we really realize the effect of adding a picture in a batch in each article? You can use an interception field for two of pieces of code.
The first paragraph is to analyze the number of words in the article, and then insert the AD code:
Dim leftcontent,midadcontent,rightcontent,modifycontent,headlen,tempstr,headadstr,tailadstr
' intercepts the appropriate number of strings
If Len (articlecontent) <320 then
headlen=200
else
headlen=320 end
if
tempstr= Articlecontent
leftcontent=interceptstring (tempstr,headlen)
' obtains the intercepted text content
Rightcontent=right ( Articlecontent,len (articlecontent)-len (leftcontent)
modifycontent=leftcontent & "<div style=" "Float: Left; "" ><script language= "javascript" "src=" "Http://www.eryi.org/ad.js" "></script></div>" & Rightcontent
Above is through the DIV+JS to insert the advertisement, the advertisement code is placed in the Ad.js file, can also through TABLE+JS or directly with the IFRAME way inserts. In that way, you must set its properties to left or right, so that you can be sure to wrap around the ad.
Then the second paragraph is the drawing of the code to draw the judgment of the advertising.
Function interceptstring (txt,length) Dim x,y,ii,c,ischines,isascii,tempstr txt=trim (txt) x = len (txt) y = 0 if x >= 1 Then for II = 1 to x C=ASC (Mid (txt,ii,1)) if c< 0 or C >255 Then ' description is a chinese character y = y + 2 Ischines=1 isascii=0 el Se ' Description is an ASCII code y = y + 1 ischines=0 isascii=1 End If ' If the length is longer than the defined substring length, determine if the containing sensitive string separates the if Y >= length then if Ischines=1 and Strcount (left (trim (TXT), II, "<a") =strcount (Left (trim (TXT), ii), "</a>") then txt = left ( TXT), ii) ' string long exit for else if Isascii=1 then x=x+1 End If Next interceptstring = txt else intercepts Tring = "" End If End Function ' determines the number of occurrences of a string function Strcount (str,substr) Dim istrcount Dim Istrstart Dim Itemp Istrco UNT = 0 Istrstart = 1 itemp = 0 str=lcase (str) substr=lcase (SUBSTR) Do While Istrstart < Len (str) itemp = INSTR (i
Strstart,str,substr,vbtextcompare) If itemp <=0 Then istrstart = Len (Str) Else Istrstart = itemp + Len (SUBSTR)
Istrcount = Istrcount + 1End If Loop strcount = Istrcount End Function
Take the new cloud Web site management system as an example. First find the code file to grow the static article page/inc/newschannel.asp (other CMS is similar to this), in line No. 248 = Replace (Htmlcontent, "{$ArticleContent}", Articlecontent) Inserts the first paragraph of code in front of the page, inserts the second paragraph of code as appropriate, and then changes the articlecontent in the row to modifycontent.