1

我继承了一些通常可以正常工作的冷融合代码。

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

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

您可以在此处查看实时页面。右侧顶部的“广告”应每 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);
});
4

1 回答 1

4

哦,上帝,我觉得自己很愚蠢。

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

哦,伙计,我不敢相信这很容易。我昨天大部分时间都在试图弄清楚这一点。

未来警告:除非它实际上是广告,否则不要给你的脚本.*ad.*起任何名字,因为 ABP 会看到它并在看到它时将其销毁。

于 2013-09-13T14:14:44.137 回答