自动生成广告代码
来源:互联网 发布:网络投资平台可靠吗 编辑:程序博客网 时间:2024/05/14 11:23
1.根据广告计划表返回给客户放在网站代码里的脚本,带个id
<script src="http://192.168.199.137:8080/NetworkAllies/code/getAdverCode.do?id=04e5e1d1-8148-4402-8ff5-4f11652d2e47"></script>2.当加载该网页时去后台查询该id的对象,并返回动态脚本及云上的js文件@Controller@RequestMapping(value=RequestMappingConstants.CODE)public class GetAdverCodeController {@Autowiredprivate TbAdvertisementPlanService tbAdvertisementPlanService;@RequestMapping(value = RequestMappingConstants.GETADVERCODE)@ResponseBodypublic String login(HttpServletRequest request,HttpServletResponse response,@RequestParam(value="id")String id) throws IOException{TbAdvertisementPlan row = tbAdvertisementPlanService.getAdvertisementPlan(id);response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); response.setHeader("Cache-Control", "no-cache"); PrintWriter out = response.getWriter(); out.println(" var yP_statsUrl='"+ row.getAdverTargetUrl()+"';");out.println(" var yP_unionUrl='"+"www.fjs360.com"+"';");out.println(" var yP_width="+row.getAdverWidth()+";");out.println(" var yP_height="+row.getAdverHeight()+";");out.println(" var yP_imgurl='"+row.getAdverImageFlashAbsolute()+"';");out.println(" var yP_imgServer='"+"www.fjs360.com"+"';");out.println(" var yP_planType='"+"cpv"+"';");out.println(" var yP_tourl='"+row.getAdverTargetUrl()+"';");//注释转义字符注意要点out.println("document.write("+"\"<script src=\\\"http://"+"ou1hb9i4z.bkt.clouddn.com/adverShowJs.js\\\""+"></script>\""+");");out.flush();out.close();out = null;return null;}}3.adverShowJs文件
var $dom={ts : 0,adUrl: yP_statsUrl,adw : yP_width,adh : yP_height,Ie :(navigator.appName == "Microsoft Internet Explorer"),g : function(){var d = document.body;e=document.documentElement;if(document.compatMode=="BackCompat"){ //BackCompat:标准兼容模式关闭。 CSS1Compat:标准兼容模式开启。 获取不同模式下浏览器的宽高等元素this.w=d.clientWidth;this.h=d.clientHeight;this.l=d.scrollLeft;this.t=d.scrollTop;}else {this.w=e.clientWidth;this.h=e.clientHeight;this.l=e.scrollLeft==0?d.scrollLeft:e.scrollLeft;this.t=e.scrollTop==0?d.scrollTop:e.scrollTop;};},c : function (){var yP_fileext=yP_imgurl.substr(yP_imgurl.lastIndexOf(".")).toLowerCase(); //从最后一个.开始截取,转换小写var doc=document;this.popup = doc.createElement("div"); //创建divs = this.popup.style;s.overflow = "hidden"; //内容会被修剪,并且其余内容是不可见的。s.position = "absolute";s.zIndex = 1000000;s.width = (this.adw+8)+"px";s.height = (this.adh+34)+"px";s.border= 0;s.textAlign='left';if(yP_fileext!='.swf'){if(yP_planType=='cpv') {this.stra = "<a target='_blank' href="+yP_tourl+" onclick='$dom.uc()'><img src='"+yP_imgurl+"' border='0' width='"+(this.adw)+"' height='"+(this.adh)+"'></a>";}else{this.stra = "<a target='_blank' href="+this.adUrl+" onclick='_zh_(event)' onmouseover='_zv_();_zn_(event);_zt_(event)' onmousedown='_zc_(event)' onmouseup='_zc_(event)'><img src='"+yP_imgurl+"' border='0' width='"+(this.adw)+"' height='"+(this.adh)+"'></a>";}yP_C_zy_str="<table width='"+(this.adw+4)+"' height='"+(this.adh+4)+"' border='0'cellpadding='0' cellspacing='0' style=' border:4px solid #A52911'><tr><td height='25' bgcolor='#A52911'><div style='background-image: url("+yP_imgServer+"/images/copy.png);*background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+yP_imgServer+"/images/copy.png);background-repeat:no-repeat;height:25px;width:90px;'><a href='http://"+yP_unionUrl+"' target='_blank' style='height:25px;width:90px;display:block;'></a></div></td></tr><tr><td>"+this.stra+"</td></tr></table>";}else { //视频?if(yP_planType=='cpv') {this.stra = "<a target='_blank' href="+yP_tourl+" onclick='$dom.uc()'>";}else{this.stra = "<a target='_blank' href="+this.adUrl+" onclick='_zh_(event)' onmouseover='_zv_();_zn_(event);_zt_(event)' onmousedown='_zc_(event)' onmouseup='_zc_(event)'>";}dL_flash = this.F("pf_123",yP_imgurl, this.adw, this.adh);yP_C_zy_str="<table width='"+(this.adw+4)+"' height='"+(this.adh+4)+"' border='0' cellpadding='0' cellspacing='0' style=' border:4px solid #A52911'><tr><td height='25' bgcolor='#A52911'><div style='background-image: url("+yP_imgServer+"/images/copy.png);*background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+yP_imgServer+"/images/copy.png);background-repeat:no-repeat;height:25px;width:90px;'><a href='http://"+yP_unionUrl+"' target='_blank' style='height:25px;width:90px;display:block;'></a></div></td></tr><tr><td>"+this.stra+"<div style='cursor:pointer;z-index:100000;position:absolute;height:"+this.adh+"px;width:"+this.adw+"px;background-color:#fff;opacity:0.01;filter:alpha(opacity:1);'></div></a><div style=' z-index:9999;cursor:pointer;text-align:center' >"+dL_flash+"</div></td></tr></table>";}this.popup.innerHTML='<span style="position:absolute;top:2px;right:12px;cursor:pointer;;z-index:111;font-size:16px;color:#ffffff" onclick="$dom.hi()">x</span>'+yP_C_zy_str+''; //拼接divs.display="none";if(this.Ie) {document.body.insertBefore(this.popup) ;} else {document.body.appendChild(this.popup);} },hi : function(){ clearInterval($dom.sI); document.body.removeChild(this.popup); //DIV隐藏},s : function (){clearInterval($dom.zy); //清除周期性执行的代码setTimeout(function(){$dom.r();},50); //50ms后执行r方法 },r: function (){$dom.c();$dom.sI=setInterval(function(){$dom.m();},10); //获取此周期执行ID以便结束该循环 根据滚动条时时},m: function (){ $dom.g(); //获取浏览器属性this.popup.style.left=(this.w-this.adw+this.l-8)+"px";this.popup.style.top=(this.h-this.ts+this.t-34)+"px"; this.popup.style.display="";if(this.ts<this.adh){this.ts+=7;if(this.ts>this.adh){this.ts=this.adh;if(this.ts-10>this.adh) clearInterval($dom.sI);};};},uc :function(){ //给浏览器缓存一张图片 a=new Image(); a.src=yp_doclick2url;},t: function (){if(window.attachEvent){ //监听事件,窗口加载 非IE浏览器window.attachEvent("onload",function (){$dom.s();});}else {window.addEventListener("load",function (){ //IE浏览器$dom.s();},true);}if(yP_planType=='cpv'){ //如果是cpv 5000ms后执行Va方法setTimeout(function(){$dom.Va();},5000);}},Va: function (){if(document.body){ //body对象zY_a=new Image();zY_a.src=yP_statsUrl; //给浏览器缓存一张图片}},F : function(idad, swfurl, ws, hs){ var str = '<embed src="'+swfurl+'" type="application/x-shockwave-flash" height="'+hs+'" width="'+ws+'" id="'+idad+'" name="ZyadsFlashAd" quality="high" wmode="transparent" allownetworking="none" allowscriptaccess="always" >';return str;}};$dom.t();
阅读全文
1 0
- 自动生成广告代码
- 代码自动生成.
- 自动生成代码
- 代码自动生成软件
- ALV自动生成代码
- CodeSmith自动生成代码
- java代码自动生成
- 代码自动生成工具
- 自动代码生成
- MBG自动代码生成
- 自动生成代码实用工具
- matlab自动代码生成
- 自动生成代码实用工具
- 代码自动生成
- hand代码自动生成
- yii 自动生成代码
- 代码自动生成
- thinkphp 代码自动生成
- java工厂模式实例讲解
- 51Nod 1102 面积最大的矩形
- 下拉刷新框架android-Ultra-Pull-To-Refresh导入到Android Studio
- JavaEE面试题库分类及答案之三
- 西安集训第二天---状压dp
- 自动生成广告代码
- HDOJ1398 母函数题目
- 实习项目三总结
- HQL查询
- 图像处理之Matlab特征提取和表达
- 5-6 集合相似度 (25分)
- Excel在统计分析中的应用—第六章—概率分布及概率分布图-Part2-离散型概率分布(二项分布函数CRITBINOM的应用)
- <转>将Django models 和views拆分程多个文件
- ASL Code中的_DSM方法