原帖由 BingQ 于 2006-4-22 11:06 发表
主题推广代码分两部分,可以将第一部分的内容全放在js文件中,只在网页中写入第2段代码即可
此方法未经官方确认大家有使用的可以向百度咨询一下 哪两部分呢?我用下面的方法可以吗?
QUOTE:
var arrBaiduCproConfig=new Array();
arrBaiduCproConfig['uid'] =我的ID;
arrBaiduCproConfig['n'] ='ID';
arrBaiduCproConfig['tm'] = 16;
arrBaiduCproConfig['cm'] = 0;
arrBaiduCproConfig['um'] = 0;
arrBaiduCproConfig['rad'] = 1;
arrBaiduCproConfig['w'] = 400;
arrBaiduCproConfig['h'] = 15;
arrBaiduCproConfig['bd'] = '#FFFFFF';
arrBaiduCproConfig['bg'] = '#FFFFFF';
arrBaiduCproConfig['tt'] = '#ff0000';
arrBaiduCproConfig['ct'] = '#000000';
arrBaiduCproConfig['url'] = '#666666';
arrBaiduCproConfig['bdl'] = '#FFFFFF';
arrBaiduCproConfig['wn'] = 3;
arrBaiduCproConfig['hn'] = 1;
arrBaiduCproConfig['ta'] = 'right';
arrBaiduCproConfig['tl'] = 'bottom';
arrBaiduCproConfig['bu'] = 0;
var intBaiduCproDebug = 0;
var strBaiduCproUiUrl = 'http://cpro.baidu.com/cpro/ui/uijs.php?';
function baiduCproWriteStyle()
{
strBaiduCproStyle = '<style type="text/css">'
strBaiduCproStyle += '<!--';
strBaiduCproStyle += 'table.baidu_cpro_table td,table.baidu_cpro_table a,table.baidu_cpro_table div{font-size:12px;font-family:"宋体","楷体_gb2312","楷体";table-layout:fixed; word-break:break-all;vertical-align: middle; overflow:hidden;}';
strBaiduCproStyle += 'table.baidu_cpro_table a:link.baidu_cpro_title,table.baidu_cpro_table a:visited.baidu_cpro_title{text-decoration:none;}';
strBaiduCproStyle += 'table.baidu_cpro_table a:active.baidu_cpro_title,table.baidu_cpro_table a:hover.baidu_cpro_title{text-decoration:underline;}';
strBaiduCproStyle += '//-->';
strBaiduCproStyle += '</style>';
return strBaiduCproStyle;
}
function baiduCproTableBuild(strBaiduCproData, bolDebug){
//参数定义
intBaiduCproRow=arrBaiduCproConfig['hn'];
intBaiduCproCol=arrBaiduCproConfig['wn'];
intBaiduCproTdWidth = Math.ceil(100/intBaiduCproCol)+'%';
intBaiduCproTdHeight = Math.ceil((arrBaiduCproConfig['h']-16)/intBaiduCproRow)-4;
strBaiduCproTitleText = '服务';
strBaiduCproTitleUrl = 'http://union.baidu.com/';
//数据分割
arrBaiduCproData = strBaiduCproData.split('\n');
for(i=0;i<arrBaiduCproData.length;i++){
arrBaiduCproData<i> = arrBaiduCproData<i>.split('\t');
}
//table头
strBaiduCproOut = '<table align=center width='+arrBaiduCproConfig['w']+' height='+arrBaiduCproConfig['h']+' cellpadding=1 cellspacing=0 bgcolor='+arrBaiduCproConfig['bd']+' style="border:1px solid '+arrBaiduCproConfig['bd']+';" class="baidu_cpro_table">';
//百度title
strBaiduCproTitle = '<tr>';
strBaiduCproTitle += '<td height=12 colspan='+arrBaiduCproConfig['wn']+' align='+arrBaiduCproConfig['ta']+' bgcolor='+arrBaiduCproConfig['bd']+' style="border:0px; border-top:1px solid '+arrBaiduCproConfig['bd']+'; background-color:'+arrBaiduCproConfig['bd']+';color:'+arrBaiduCproConfig['bdl']+';">';
strBaiduCproTitle += strBaiduCproTitleText;
strBaiduCproTitle += '</td></tr>';
//百度title位置为top
if(arrBaiduCproConfig['tl'] != 'bottom'){
strBaiduCproOut+=strBaiduCproTitle;
}
index =0;
for(i=0;i<intBaiduCproRow;i++){
strBaiduCproOut +='<tr bgcolor=white>';
for(j=0;j<intBaiduCproCol;j++){
strBaiduCproOut +='<td style="border:0px;'+(i!=0?' border-top:1px solid '+arrBaiduCproConfig['bd']+';':'')+' background-color:'+arrBaiduCproConfig['bg']+';width:'+intBaiduCproTdWidth+'; height:'+intBaiduCproTdHeight+'px;" bgcolor="'+arrBaiduCproConfig['bg']+'" height="'+intBaiduCproTdHeight+'"width="'+intBaiduCproTdWidth+'" valign="middle">';
if (index>=arrBaiduCproData.length)
{
break;
}else{
if(arrBaiduCproData[index][3].match(/^http:\/\/sf\.baidu\.com\/cpro\.php/ig)){
arrBaiduCproData[index][3]+='&referer='+location.href.replace(/^.*&word=([^&]+).*$/ig,'$1');
}
strBaiduCproOut +='<div><a href="'+arrBaiduCproData[index][3]+'" target="_blank" class="baidu_cpro_title" style="color:'+arrBaiduCproConfig['tt']+';font-weight:bold;"><b>';
strBaiduCproOut +=arrBaiduCproData[index][0]+'</b></a></div>';
strBaiduCproOut +='<a href="'+arrBaiduCproData[index][3]+'" target="_blank" style="text-decoration:none;">';
if (arrBaiduCproData[index][1] != '...'){
strBaiduCproOut +='<div style=" color:'+arrBaiduCproConfig['ct']+';text-decoration:none;">'+arrBaiduCproData[index][1]+'</div>';
}
if(arrBaiduCproConfig['bu']=='1' || arrBaiduCproConfig['bu']==1){
strBaiduCproOut +='<div style="color:'+arrBaiduCproConfig['url']+';text-decoration:none;">'+arrBaiduCproData[index][2].replace(/^(\w+:\/\/)?([^\/]+).*$/ig,'$2')+'</div>';
}
strBaiduCproOut +='</a>';
index++;
}
strBaiduCproOut +='</td>';
}
strBaiduCproOut +='</tr>';
if (index>=arrBaiduCproData.length)
{
break;
}
}
//百度title位置为top
if(arrBaiduCproConfig['tl'] == 'bottom'){
strBaiduCproOut+=strBaiduCproTitle;
}
strBaiduCproOut += '</table>';
strBaiduCproOut = baiduCproWriteStyle()+strBaiduCproOut;
if (intBaiduCproDebug==1){
return strBaiduCproOut;
}else{
document.write(strBaiduCproOut);
}
}
function baiduCproGetUri(strBaiduCproUrl)
{
strBaiduCproGetParamMap = ',w|rsi0,h|rsi1,bu|rsi2,bd|rss0,bg|rss1,tt|rss2,ct|rss3,url|rss4,bdl|rss5,ta|rssl0,tl|rssl1,';
strBaiduCproUiUri = strBaiduCproUiUrl;
for (key in arrBaiduCproConfig){
if(key!='word'){
strBaiduCproUiUrlRegExp = '/^.*,'+key+'\\|([^,]+),.*$/ig';
strBaiduCproUiUrlParamName = eval('strBaiduCproGetParamMap.match(' + strBaiduCproUiUrlRegExp + ')?strBaiduCproGetParamMap.replace(' + strBaiduCproUiUrlRegExp + ',"$1":"' + key + '"');
strBaiduCproUiUri += '&'+strBaiduCproUiUrlParamName+'='+escape(arrBaiduCproConfig[key]);
}
}
if (strBaiduCproUrl==''){
strBaiduCproUrl=location.href
}
strBaiduCproUiUri += '&word=';
strBaiduCproUiUri += typeof(encodeURIComponent)=='function' ? encodeURIComponent(strBaiduCproUrl) : escape(strBaiduCproUrl);
return strBaiduCproUiUri;
}
function baiduCproIFrame()
{
return '<iframe marginWidth=0 marginHeight=0 scrolling=no frameBorder=0 width='+arrBaiduCproConfig['w']+' height='+arrBaiduCproConfig['h']+' allowTransparency src="'+baiduCproGetUri('')+'"></iframe>';
}
document.write(baiduCproIFrame()); |