jQueryの新機能であり、このコードの最後の部分を機能させることができません。ユーザーが一番下までスクロールしてすべてのページコンテンツを表示していない場合は、リンクをクリックしてページを離れたときに簡単なアラートを表示しようとしています。
ユーザーが次のページに移動できないようにする必要があるかどうかはまだわかりませんが、今のところ、ユーザーが一番下に到達したかどうかを検出する部分を取得して、自分のコードで機能させるようにします。私はすでにスクロールバーがあるかどうかを検出し、ユーザーが一番下に到達したときに登録する方法に固執している部分を持っています:
jQuery:
<script>
$(document).ready(function() {
var verticalScrollPresent = function() {
return document.documentElement.scrollHeight !== document.documentElement.clientHeight;
}
$('#nav').click(function() {
if (verticalScrollPresent) {
//imagining that this is where the code will go, but how can I register that the user has scrolled to the bottom?
alert("There's a whole bunch of stuff you haven't seen yet!");
}
});
});
</script>
HTML
<a id="nav" href="http://google.com">Next page</a>