TripAdvisor Javascript小工具 - 未加载

时间:2017-05-31 19:13:57

标签: javascript

我正在尝试在我公司的网站上使用一些TripAdvisor小部件。但是,它们没有正确加载(只显示徽标)。我看过herehere;但是,我的应用程序在相关页面上既不使用AJAX也不使用AngularJS。

来源:

    <?php
$title = "Business and Meeting Facilities - Auburn Place, Cape Giradeau";
include_once("../config.php");
$cssIncludes = "<link rel='stylesheet' href='"  .  STYLEPATH . "hotels.css'>";
include(INCLUDEROOT . "includes/header.php");
include("hotel_header.php");
include("hotel_sidebar.php");
?>

<!-- Page Specific Content -->

<div class='col-md-6 hotelBody'>

<h3>Facilities - Auburn Place, Cape Girardeau, MO</h3>

 <div class="row"><div class="col-md-12"><h4>Terrace Room</h4><p>The Auburn Place Hotel &amp; Suites Cape Girardeau has a spacious room for small gathering and meetings located on the second floor (accessible by stairs only). The Terrace room features a pre-function area ideal for registration outside of the room that overlooks the beautiful Breakfast Court. Please contact our sales team at <?php echo $hotel->phone; ?> for more details.</p> </div>
</div>

<img class="img-responsive" src="<?php echo HOTEL_IMAGEPATH;?>apcap (23).JPG" alt="The Terrace Room" />

 <div class="row"><div class="col-md-12"><h4>Specifications and Features </h4><ul><li>750 sq. foot Meeting Space (25 x 30)</li><li>Free WiFi</li><li>A/V Equipment Rental Available</li><li>Seating Specifications: 30 Classroom, 20 Conference, 45 Theatre, 16 U-Shape, 20 H-Square</li></ul></div></div></div>



<!-- End Page Specific Content; Begin Right Sidebar -->

<div class='col-md-3 hidden-sm hidden-xs'><div id="TA_selfserveprop32" class="TA_selfserveprop"><ul id="o7eJLMFC6gkQ" class="TA_links lPUMaPNhO"><li id="MuQlgBWB" class="VukuC82"><a target="_blank" href="https://www.tripadvisor.com/"><img src="https://www.tripadvisor.com/img/cdsi/img2/branding/150_logo-11900-2.png" alt="TripAdvisor"/></a></li></ul></div><script src="https://www.jscache.com/wejs?wtype=selfserveprop&amp;uniq=32&amp;locationId=256900&amp;lang=en_US&amp;rating=true&amp;nreviews=5&amp;writereviewlink=true&amp;popIdx=true&amp;iswide=false&amp;border=false&amp;display_version=2"></script></div>
<div class='col-sm-12 hidden-md hidden-lg visible-sm visible-xs '><div id="TA_cdsratingsonlywide15" class="TA_cdsratingsonlywide"><ul id="WOmK1MXNTk" class="TA_links X2Pm5R"><li id="cquenz3zRw" class="PBwjsw"><a target="_blank" href="https://www.tripadvisor.com/"><img src="https://www.tripadvisor.com/img/cdsi/img2/branding/tripadvisor_logo_transp_340x80-18034-2.png" alt="TripAdvisor"/></a></li></ul></div><script src="https://www.jscache.com/wejs?wtype=cdsratingsonlywide&amp;uniq=15&amp;locationId=256900&amp;lang=en_US&amp;border=true&amp;shadow=true&amp;backgroundColor=white&amp;display_version=2"></script></div>


<?php
include(INCLUDEROOT . "includes/footer.php");
?>

我的JS的其余部分加载在页脚中:

</div>
<div class='row'>
!----- HTML / PHP CONTENT OMITTED -----!
  <script type="text/javascript">

function downloadJSAtOnload() {

var element = document.createElement("script");
element.src =  "/includes/scripts/analytics.js";
var bod = document.getElementsByTagName("body");
bod[0].appendChild(element);

var element = document.createElement("script");
element.src =  "/includes/scripts/slicknav.js";
var bod = document.getElementsByTagName("body");
bod[0].appendChild(element);

var element = document.createElement("script");
element.src =  "/includes/scripts/base.js";
var bod = document.getElementsByTagName("body");
bod[0].appendChild(element);

}
 window.onload = downloadJSAtOnload();
</script>
<script src='<?php echo SCRIPTPATH ?>jquery.js'></script>

<script src='<?php echo SCRIPTPATH; ?>nivoslider.js'></script>
     <script>$(document).ready(function() { $('#homeSlider').nivoSlider( { controlNav: false, pauseTime: 8000, effect: 'boxRainGrow', directionNav: false });
     $('.promotionSlider').nivoSlider( {effect: 'fold'} );
     });</script>
       <script src='<?php echo SCRIPTPATH ?>bootstrap.js'></script>




<!-- Used to include any Javascript that may be unqiue to a single or small number of pages. -->
<?php isset($jsIncludes) ? print $jsIncludes : " " ?>
</body>
</html>

据我所知,代码一直在工作,直到我实现了downloadJSAtOnload()函数(我根据文章的建议创建了减少渲染阻塞Javascript)。

呈现的代码具有以下形式:

<div class="col-md-3 visible-md visible-lg hidden-sm hidden-xs ">
  <div id="TA_selfserveprop32" class="TA_selfserveprop">
    <ul id="o7eJLMFC6gkQ" class="TA_links lPUMaPNhO">
      <li id="MuQlgBWB" class="VukuC82">
        <a target="_blank" href="https://www.tripadvisor.com/"><img src="https://www.tripadvisor.com/img/cdsi/img2/branding/150_logo-11900-2.png" alt="TripAdvisor"></a>
      </li>
    </ul>
  </div>
  <script src="https://www.jscache.com/wejs?wtype=selfserveprop&amp;uniq=32&amp;locationId=256900&amp;lang=en_US&amp;rating=true&amp;nreviews=5&amp;writereviewlink=true&amp;popIdx=true&amp;iswide=false&amp;border=false&amp;display_version=2"></script>
  <script src="https://www.tripadvisor.com/WidgetEmbed-selfserveprop?border=false&amp;popIdx=true&amp;iswide=false&amp;locationId=256900&amp;display_version=2&amp;uniq=32&amp;rating=true&amp;lang=en_US&amp;nreviews=5&amp;writereviewlink=true"></script>
</div>
<div class="col-sm-12 hidden-md hidden-lg visible-sm visible-xs ">
  <div id="TA_cdsratingsonlywide15" class="TA_cdsratingsonlywide">
    <ul id="WOmK1MXNTk" class="TA_links X2Pm5R">
      <li id="cquenz3zRw" class="PBwjsw">
        <a target="_blank" href="https://www.tripadvisor.com/"><img src="https://www.tripadvisor.com/img/cdsi/img2/branding/tripadvisor_logo_transp_340x80-18034-2.png" alt="TripAdvisor"></a>
      </li>
    </ul>
  </div>
  <script src="https://www.jscache.com/wejs?wtype=cdsratingsonlywide&amp;uniq=15&amp;locationId=256900&amp;lang=en_US&amp;border=true&amp;shadow=true&amp;backgroundColor=white&amp;display_version=2"></script>
  <script src="https://www.tripadvisor.com/WidgetEmbed-cdsratingsonlywide?border=true&amp;backgroundColor=white&amp;shadow=true&amp;locationId=256900&amp;display_version=2&amp;uniq=15&amp;lang=en_US"></script>
</div>


</div>
<div class="row">
</div>
<div class='row'>
  !----- HTML CONTENT OMITTED -----!
  <script type="text/javascript">
    function downloadJSAtOnload() {

      var element = document.createElement("script");
      element.src = "/includes/scripts/analytics.js";
      var bod = document.getElementsByTagName("body");
      bod[0].appendChild(element);

      var element = document.createElement("script");
      element.src = "/includes/scripts/slicknav.js";
      var bod = document.getElementsByTagName("body");
      bod[0].appendChild(element);

      var element = document.createElement("script");
      element.src = "/includes/scripts/base.js";
      var bod = document.getElementsByTagName("body");
      bod[0].appendChild(element);

    }
    window.onload = downloadJSAtOnload();
  </script>
  <script src="/includes/scripts/analytics.js"></script>
  <script src="/includes/scripts/slicknav.js"></script>
  <script src="/includes/scripts/base.js"></script>
  <script src="/includes/scripts/jquery.js"></script>

  <script src="/includes/scripts/nivoslider.js"></script>
  <script>
    $(document).ready(function() {
      $('#homeSlider').nivoSlider({
        controlNav: false,
        pauseTime: 8000,
        effect: 'boxRainGrow',
        directionNav: false
      });
      $('.promotionSlider').nivoSlider({
        effect: 'fold'
      });
    });
  </script>
  <script src="/includes/scripts/bootstrap.js"></script>




  <!-- Used to include any Javascript that may be unqiue to a single or small number of pages. -->


  </body>

  </html>   

我不太清楚为什么附加到window.onload的函数会干扰窗口小部件的加载,但这是我唯一能想到的。关于为什么会出现这个问题或如何解决这个问题的任何建议,将不胜感激。

0 个答案:

没有答案