问答详情
源自:-

滚动轴滚动到底部和顶部

<!DOCTYPE html>

<html>

<head>

<meta charset="{CHARSET}">

<title>"滚动轴滚动到底部和顶部</title>

http://img.mukewang.com/58d52cd20001b07c04390145.jpg

http://img.mukewang.com/58d52d1700016c0010570541.jpg

</head>

<body>

<div class="scrollDiv"></div>

<style type="text/css">

.scrollDiv{

width:500px;

height: 400px;

margin: 1000px auto 100px auto;

background-color:aquamarine;

}

</style>

<script type="text/javascript">

function scrollBottomOrTop(){                           /*封装一个函数*/

var clients=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;/*k可视区域的一个高度*/

var scrollTop=document.body.scrollTop;/*卷上去的部分*/

var wholeheheigt=document.body.scrollHeight;/*scrollHeight在document是整个内容的高度+padding+mar+body的这么一个高度*/

if(clients+scrollTop>=wholeheheigt){

alert("我已经滚动到了底部!")

}

if(scrollTop==0){

alert("我已经滚动到了顶部!")

}

}

window.onscroll=scrollBottomOrTop;

</script>

</body>

</html>

老师这个在浏览器输出不了文字,而是出现不知名的字体怎么回事,在IE和谷歌都是如此

提问者:慕粉3397126 2017-03-24 22:29

个回答

  • 慕用8740379
    2017-11-11 11:39:21

    在<head>标签里面加上<meta charset="UTF-8">就好了,解析中文字体的,不用中文字体就会乱码