我的Javascript在Chrome中运行,而非Firefox

时间:2013-12-09 03:09:06

标签: javascript jquery google-chrome firefox console

我已经在Chrome控制台中运行以下代码,它运行正常。当我尝试在firebug控制台中运行并滚动到页面底部的触发点时,没有任何反应。任何人都可以帮助ID为什么这不适用于Firefox?

CartSummaryOverlay = {
  activate: document.body.parentNode.scrollHeight * 0.9,
  limit: 0,
  totalItems: parseInt(jQuery('span.cart-total-qty').text()),
  loadSummary: function(){
      if (CartSummaryOverlay.totalItems > 0) {  
        jQuery.get("/checkout/cart", function(html){
          CartSummaryOverlay.total = jQuery("td.total span.price span", html).text();
          CartSummaryOverlay.CreateOverlayBackground();
          CartSummaryOverlay.RemoveOverlayBackground();
        });
      } else {
        CartSummaryOverlay.total =  "0";
        CartSummaryOverlay.CreateOverlayBackground();
        CartSummaryOverlay.RemoveOverlayBackground();
      }
  },
  CreateOverlayBackground: function(){
    $overlay = jQuery("<div id='overlay' style='background-color: #000; opacity: .85; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; color: white; text-align: center; font-size: 200%;'></div>");
    $overlay.html('<div style="position: fixed; top: 40%; left: 38%;">Number of Items in Cart: '+CartSummaryOverlay.totalItems+'<br>Total: '+CartSummaryOverlay.total+'</div><div id="close_overlay"><a id="closing_tag" style="top: 35%; right: 38%; color: white; position: fixed; font-size: 50%;">X</a></div>');
    jQuery("body").append($overlay);
  },
  pageScroll: function(){
    var current_height = document.body.scrollTop + document.body.clientHeight;
    if (current_height >= CartSummaryOverlay.activate && CartSummaryOverlay.limit === 0) {
      CartSummaryOverlay.loadSummary();
      CartSummaryOverlay.limit += 1;
    }
  },
  RemoveOverlayBackground: function(){
    // setTimeout(function(){
      jQuery('#closing_tag').click(function(){
      jQuery("#overlay").remove();
      CartSummaryOverlay.limit = 0;
      });
  }
}


window.onscroll = CartSummaryOverlay.pageScroll;

0 个答案:

没有答案