Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (36 sloc) 962 Bytes
<html>
<head>
<meta charset="utf-8">
<title>remember-scroll examples</title>
<style>
#content, p{
text-align: center;
}
</style>
</head>
<body>
<p>你可以滚动到任意位置并记住数字,然后再关闭页面甚至关闭浏览器,最后再次打开该页面,你会发现打开时会自动滚动到你离开时的位置。</p>
<div id="content"></div>
<script src="../dist/remember-scroll.min.js"></script>
<script>
window.onload = function () {
var content = document.getElementById('content')
var str = ''
for (var i = 0; i < 200; i++) {
str += '<p>'+ i +'</p>'
}
content.innerHTML = str
// use RememberScroll
new RememberScroll()
// test onscroll
window.onscroll = function(){
console.log('log')
}
// test addEventListener way
window.addEventListener('scroll', function () {
console.log('addEventListener log')
})
}
</script>
</body>
</html>
You can’t perform that action at this time.