// When the user scrolls down 20px from the top of the document, show the button document.getElementById("mydiv").onscroll = function() {scrollFunction()}; function scrollFunction() { //document.getElementById("myBtn").style.display = "block"; if (document.getElementById("mydiv").scrollTop > 20 || document.documentElement.scrollTop > 20) { document.getElementById("myBtn").style.display = "block"; } else { document.getElementById("myBtn").style.display = "none"; } } // When the user clicks on the button, scroll to the top of the document function topFunction() { document.getElementById("mydiv").scrollTop = 0; document.documentElement.scrollTop = 0; //var cursc = document.getElementById("mydiv").scrollTop(); //alert(Math.max(document.documentElement.clientHeight, window.innerHeight || 0)); } function pgdown(){ var viewheight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); document.getElementById("mydiv").scrollTop += 5*viewheight/6; document.documentElement.scrollTop += 5*viewheight/6; } function pgup(){ var viewheight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); document.getElementById("mydiv").scrollTop -= 5*viewheight/6; document.documentElement.scrollTop -= 5*viewheight/6; } function viewport() { var e = window, a = 'inner'; if ( !( 'innerWidth' in window ) ) { a = 'client'; e = document.documentElement || document.body; } return { width : e[ a+'Width' ] , height : e[ a+'Height' ] } } /*can prevent scrolling? $(".ToolPage").bind('mousewheel', function(e, d) var t = $(this); if (d > 0 && t.scrollTop() === 0) { e.preventDefault(); } else { if (d < 0 && (t.scrollTop() == t.get(0).scrollHeight - t.innerHeight())) { e.preventDefault(); } } });*/