javascript - Firefox 和 Chrome 不从 coldfusion 加载脚本包括?

标签 javascript google-chrome firefox coldfusion

我继承了一些通常运行良好的冷融合代码。

我遇到的问题是在一个包含拒绝加载特定脚本的 cfinclude 的页面上。如果它没有在它之前的行加载脚本,我几乎不会感到困扰,但它确实如此。

Firefox 甚至不会尝试获取脚本(就 fiddler 而言),而 chrome 也无法获取它(除非您在打开 chrome 时打开了该页面,在这种情况下它会一直工作直到您刷新这一页)。然而,Internet Explorer 在这方面做得很好并且加载它也很好!

可以看到直播页面here .右侧顶部的“广告”应该每 4 秒淡出并淡入一个新广告。

这是调用脚本 (adrotator.js) 的地方。 jQuery.js 加载正常,我放入的 alert 也工作正常(在未加载的脚本之上或之下):

<cfsilent>
    <!--- THIS IS THE LIST OF LARGE ADS FOR IN THE LARGE AD ROTATOR --->
    <cfinclude template="ads/adlist_inc.cfm">
    <!--- PUT IN THE NUMBER OF LARGE ADS HERE --->
    <cfset adListLarge = GetNumAds("large", 0)> <!--- 0 means all the ads --->
</cfsilent>
<script language="javascript" type="text/javascript" src="/locations/js/jquery.js"></script>
<script type="text/javascript">
    alert("test!") <!--- WHY DOES THIS WORK --->
</script>
<!--- WHEN THIS DOESN'T WORK? --->
<script language="javascript" type="text/javascript" src="/locations/js/adrotator.js"></script>

<div id="spotlight_ad_top">
<cfoutput><cfset temp = MakeAllAdImgTags(adListLarge)>#temp#</cfoutput>
</div>

这个页面被这样调用:

<!-- TOP SPOTLIGHT GRAPHICS IN RIGHT COLUMN -->
<div id="locations-branchleaf-spotlight">
<!--- THIS PULLS THE LOCATION SPECIFIC AD IMAGE IF THERE IS ONE  --->
<cfoutput query="ReturnLocationInfo">
        <cfinclude template="../#initials#/spotlightcontent_inc.cfm">
</cfoutput>
<!-- THIS DISPLAYS THE LOCATION-WIDE PROMOTIONAL SPOTLIGHT -->
<cfinclude template="/locations/includes/spotlightcontent_inc.cfm">
</div>

依次调用它:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--- THIS IS THE INCLUDED PAGE FOR EACH LOCATION'S HOME PAGE INDEX.CFM --->
<cfset PAGE_TITLE = ReturnLocationInfo.name & " - Carnegie Library of Pittsburgh">
<title><cfoutput>#PAGE_TITLE#</cfoutput></title>
<cfinclude template="/includes/header-locations-branchleaf_inc.html">
<cfinclude template="../breadcrumb_inc.html">

<div id="content">
<!-- THIS BRANCH/DEPARTMENT'S NAME, DUMP THE DASH IF IT IS THE pop-up -->
<h1><cfif locationID is 92><cfelse>CLP &ndash; </cfif><cfoutput>#ReturnLocationInfo.name#</cfoutput></h1>
<!-- BRANCH LEAF - LEFT COLUMN: LOCATION PHOTO & CONTACT INFO, HOURS EVENTS, LINKS  -->
<div id="leftcolumn">
<!-- 1: LOCATION'S PHOTO/CONTACT INFO WITH LINKSTO DIRECTIONS AND CONTACT FORM -->
<cfinclude template="information_inc.cfm">

<!-- 2: LOCATION'S EMERGENCY NOTICE PULLED FROM TAB MGR NOTICES (SPOTLIGHTS) -->
<cfinclude template="notice_inc.cfm">

<!-- 3: LOCATION'S HOURS GRID -->
<cfinclude template="hours_inc.cfm">

<!-- Testing out location specific notifications! -->
<cfinclude template="notification_inc.cfm">

<!-- 4: LOCATION'S EVENTS -->
<!--- IF THIS IS THE PCCENTER (13) OR JCEC (6), INCLUDE THE programs_inc.cfm IN /locations/pccenter/ --->
<cfif locationID IS 13 or locationID IS 6>
    <cfinclude template="/locations/pccenter/programs_inc.cfm"> 
<cfelse>
    <cfinclude template="programs_inc.cfm">
</cfif>

<!-- 5: LINKS FOR LOCATION -->
<cfinclude template="links_inc.cfm">

<!-- 6: STAFF PICK FOR LOCATION IF ONE EXISTS-->
<cfinclude template="staffpick_inc.cfm">
  </div> <!--//end leftcolumn -->

  <!-- BRANCH LEAF - RIGHT COLUMN: SPOTLIGHT, FLICKR PHOTO GALLERY -->
  <div id="rightcolumn">
<!--- LOCATION'S UNUSED MAP AND DIRECTIONS
<cfinclude template="directions_inc.cfm">  --->
<!-- 9. THE SPOTLIGHT AD - FORMERLY TOPAD -->
<cfinclude template="spotlight_inc.cfm">

<!-- 10: PHOTOS TAGGED WITH THIS BRANCH IN FLICKR -->
<cfinclude template="gallery_inc.cfm">
  </div> <!--//end rightcolumn -->
</div> <!--//end content -->
<cfinclude template="/includes/footer_inc.html">

有什么我遗漏的,为什么它不会加载脚本?如果我在新选项卡中加载脚本,它会正常连接并显示。

这是脚本:

var activeAdNum = 0;
var totAds = 0;
var adSpeed = 4*1000;
var userBusy = false;

rotate_ads = function() {
  if (userBusy){
    window.setTimeout(rotate_ads, adSpeed);
    return;
  }
  jQuery(function(){
    nextAdNum = (activeAdNum % totAds) + 1;
    $("#rotating_ad_"+activeAdNum).fadeOut(500, function(){ 
      $("#rotating_ad_"+activeAdNum).removeClass("rotating_ad_active").addClass("rotating_ad_inactive");
      $("#rotating_ad_"+nextAdNum).fadeIn("slow", function(){
        $("#rotating_ad_"+nextAdNum).removeClass("rotating_ad_inactive").addClass("rotating_ad_active");
        activeAdNum = nextAdNum;
      });
    });
  });
  window.setTimeout(rotate_ads, adSpeed);     
}

jQuery().ready(function() { 
  $(".rotating_ad").hover(
    function(){
      userBusy = true;
    },
    function(){
      userBusy = false;
    }
  );
  var adCount = 0;
  $(".rotating_ad").each(function(){adCount++;});
  totAds = adCount;
  if (totAds > 0){
    activeAdNum = 1;
  }

  window.setTimeout(rotate_ads, adSpeed);
});

最佳答案

天哪,我觉得自己很蠢。

因为它里面有“ad”这个词,adblock plus 完全阻止了它的工作(不管它只是分支上的事件)。我将尝试重命名脚本。

哦,伙计,我简直不敢相信这是那么容易。我花了昨天的大部分时间试图解决这个问题。

future 警告:除非它实际上是广告,否则不要将您的脚本称为 .*ad.* 任何东西,因为 ABP 会看到它并立即销毁它。

关于javascript - Firefox 和 Chrome 不从 coldfusion 加载脚本包括?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18787618/

相关文章:

javascript - 在正文标签的末尾渲染阻止Javascript-Firefox渲染一些视觉内容,Chrome不渲染

javascript - 在下一个 TR 上将类别添加到同一 TD

javascript - 使用 jQuery 更改段落中的符号

javascript - 如何最小化汉堡菜单的 JavaScript?

javascript - ScrollTop 在 Chrome/Safari 中不工作

html - Flexbox 在 Firefox 中看起来完全不同

google-chrome - 在浏览器上,Safari 隐私浏览中的 sessionStorage 与 Chrome 的隐身模式和 Firefox 的隐私窗口的工作方式不同吗?

html - background-position-y 在 Firefox 中不起作用(通过 CSS)?

CSS z-index 问题 : works in Firefox, 而不是 Safari?

Javascript 类型比较