上次我们讲了淘宝客如何做,但在淘宝客发展过程中,百度对垃圾淘客站也做了一些惩罚,使淘客越来越难做,有的时候页面出现大量淘宝客链接网站会被降权甚至K站,所以要想办法封装淘客链接,再从前台调用后台淘客链接,实现淘宝客链接的JS跳转,方法如下:
用JS代码来判断HTML给出的函数值来分别调用不同的URL。
需要建立两个文件,一个调用赋值HTML文件,一个执行JS文件。
1、html文件:sub.html 内容如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>请稍候......</title>
<script type="text/javascript" src="loads.js"></script> </head> <body>
</body> </html>
2、Javascript文件:loads.js 内容为:
function onloads(){ var url = location.search; /********************************************************************************************** * * 修改方法:如果销售页有多个产品,那么依次复制最后的模块,然后修改其中的链接: //模块开始 if(url=="?id=12"){ location.href=""; } //模块结束 * **********************************************************************************************/ if(url=="?id=1"){ location.href="http://www.taobao.com/go/chn/tbk_channel/channelcode.php?pid=mm_16713164_3177711_10721453&eventid=101329"; } if(url=="?id=2"){ location.href="http://www.taobao.com/go/chn/tbk_channel/channelcode.php?pid=mm_16713164_3177711_10721453&eventid=101329"; } if(url=="?id=3"){ location.href=""; } if(url=="?id=4"){ location.href=""; } if(url=="?id=5"){ location.href=""; } if(url=="?id=6"){ location.href=""; } if(url=="?id=7"){ location.href=""; } if(url=="?id=8"){ location.href=""; } if(url=="?id=9"){ location.href=""; } if(url=="?id=10"){ location.href=""; } if(url=="?id=11"){ location.href=""; } //模块开始 if(url=="?id=12"){ location.href=""; } //模块结束 } //调用函数
onloads();
操作方法:
如果销售页有10个产品,那么依次安装顺序填充location.href="淘宝客推广代码";
前台调用链接:<?php bloginfo('template_directory'); ?>/sub.html?id=1 依次类推。
例如:
<td> <div align="center"> <a target="_blank" href="<?php bloginfo('template_directory'); ?>/sub.html?id=1"> <img alt="资讯网 <第一名>" src="<?php bloginfo('template_directory'); ?>/ad/1.jpg" height="140" width="140" border="0"></a></div> </td>
有此标签“<?php bloginfo('template_directory'); ?>”的适用于wp网站。