我試圖在下面的頁面末尾觸發警報,但只要我滾動,它就會一直觸發。我嘗試了幾種不同的方法,但每次在頁面底部觸發警報。 代碼丟失只是一個數據庫調用,觸發大約20個結果,標題和一個php包含顯示結果。顯示的結果顯示了大約4個屏幕值的數據。JavaScript未在頁面末尾觸發
<body>
<div class="maincontainer">
<div class="profilecontainer">
<row>
<column cols="4" class="left">
This will have text
</column>
<column cols="8" class="right">
<ul class="post-column">
<?php
foreach ($data as $lineitem):
$type = $lineitem['type'];
if($type == "article"){
require('php/articleitem.php');
}
endforeach;
?>
</ul>
</column>
</row>
</div>
</div>
</body>
</html>
<script>
$(window).scroll(function() {
if ($(document).height() <= $(window).scrollTop() + $(window).height()) {
alert("End Of The Page");
}
});
</script>
使用您在問題中提供的代碼,這不能解決問題。我仍然可以用這個CSS重現你的問題......爲了正確地修復它,你必須定義一個文檔類型,它是[HTML語法中任何文檔的必需部分](https://www.w3)。組織/ TR/HTML的標記/ syntax.html#的doctype,語法) – trincot