我在互联网上找到了以下Javascript代码,这些代码在Chrome和Safari中运行良好。仅在Firefox和IE中,代码才会运行。还有其他选择吗?
$(function() {
var oTop = $('#counter').offset().top - window.innerHeight;
$(window).scroll(function(){
var pTop = $('body').scrollTop();
console.log( pTop + ' - ' + oTop );
if( pTop > oTop ){
start_count();
}
});
});
function start_count(){
alert('start_count');
//Add your code here
}
答案 0 :(得分:0)
答案:
$(function() {
var oTop = $('.wordpress').offset().top - $(window).height();
$(window).scroll(function(){
var scrollTop = window.pageYOffset;
if( scrollTop > oTop ){
start_count();
}
});
});