主题 : 其他页面有JS错误 |
级别: 解元
![]() |
5# 发表于:2011-11-02 11:17:19 IP:220.31.*.*
从这个action方法跳到广告版位.html
@RequestMapping(value = "/adspace.jspx") public String adspace(Integer id, HttpServletRequest request, HttpServletResponse response, ModelMap model) { CmsSite site = CmsUtils.getSite(request); if (id != null) { CmsAdvertisingSpace adspace = cmsAdvertisingSpaceMng.findById(id); List<CmsAdvertising> adList = cmsAdvertisingMng.getList(id, true); model.addAttribute("adspace", adspace); model.addAttribute("adList", adList); } FrontUtils.frontData(request, model, site); System.out.println(request.getAttribute("adList")); return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_CSI, TPL_ADSPACE); } 页面的sHtml为空或不是对象 [#if adspace?? && adspace.enabled] (function() { var Ad = function(iId,sHtml,fCode,dStart,dEnd,iWeight) { this.iId = iId; this.sHtml = sHtml; this.fCode = fCode; this.dStart = dStart; this.dEnd = dEnd; this.iWeight = iWeight; } var ads = new Array(${adList?size}); var adsLen = 0; [#list adList as ad] [#if ad.category=="image"] [#assign html] <a href="${(ad.attr.image_link)!}" target="${ad.attr.image_target!}" title="${(ad.attr.image_title)!}" onclick="$.get('${base}/ad_click.jspx?id=${ad.id}');"> <img src="${ad.attr.image_url}" border="0" [#if (ad.attr.image_width)??] width="${ad.attr.image_width}" [/#if][#if (ad.attr.image_height)??] height="${ad.attr.image_height}" [/#if]/> </a> [/#assign] ads[adsLen++] = new Ad(${ad.id},"${html?js_string}",null, [#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if], [#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if], ${ad.weight}); [#elseif ad.category=="flash"] [#assign html] <embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" menu="true" src="${(ad.attr.flash_url)!}" [#if ad.attr.flash_width?? && ad.attr.flash_width!="" ] width="${ad.attr.flash_width}" [/#if][#if ad.attr.flash_height?? && ad.attr.flash_height!="" ] height="${ad.attr.flash_height}"[/#if]></embed> [/#assign] ads[adsLen++] = new Ad(${ad.id},"${html?js_string}",null, [#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if], [#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if], ${ad.weight}); [#elseif ad.category=="text"] [#assign html] <a href="${(ad.attr.text_link)!}" target="${(ad.attr.text_target)!}" onclick="$.get('${base}/ad_click.jspx?id=${ad.id}');"> <span style="if (ad.attr.text_color)??]color: ${ ad . attr . text_color">${(ad.attr.text_title)!}</span> </a> [/#assign] ads[adsLen++] = new Ad(${ad.id},"${html?js_string}",null, [#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if], [#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if], ${ad.weight}); [#elseif ad.category=="code"] ads[adsLen++] = new Ad(${ad.id},null,function(){${ad.code!}}, [#if ad.startTimeMillis??]new Date(${ad.startTimeMillis})[#else]null[/#if], [#if ad.endTimeMillis??]new Date(${ad.endTimeMillis})[#else]null[/#if], ${ad.weight}); [#else] document.write("未知的广告类型:${ad.category!}"); [/#if] [/#list] var indexArr = new Array(); var now = new Date(); for(var i=0,j=0,len=ads.length;i <len ;i++){ if((!ads[i].dStart || now> ads[i].dStart) && (!ads[i].dEnd || now <ads [i].dEnd)) { for(var max=j+ads[i].iWeight;j <max ;j++) { indexArr[j] =i; } } } var rand=parseInt(Math.random() * indexArr.length); var show=ads[indexArr[rand]]; if(show.sHtml) { document.write(show.sHtml); } else { show.fCode(); } $.get("${base}/ad_display.jspx?id="+show.iId);})(); [#else] 广告版位不存在 [/#if] |
||
---|---|---|---|
级别: 解元
![]() |
7# 发表于:2011-11-02 11:49:53 IP:220.31.*.*
这是贴出来的相关代码,不是错误信息,能不能知道是什么原因导致js错误
好像就这里 var Ad = function(iId,sHtml,fCode,dStart,dEnd,iWeight) { this.sHtml= sHtml; this.iId = iId; this.fCode = fCode; this.dStart = dStart; this.dEnd = dEnd; this.iWeight = iWeight; } |
||
---|---|---|---|
1
共1页