Skip to content

Instantly share code, notes, and snippets.

@walterrenner
Created December 7, 2012 08:42
Show Gist options
  • Save walterrenner/4231834 to your computer and use it in GitHub Desktop.
Save walterrenner/4231834 to your computer and use it in GitHub Desktop.
Detect Scroll Position and act
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Detect Scroll Position and act</title>
<!-- CSS -->
<style type="text/css">
</style>
</head>
<body>
<div id="header">
header
</div>
<div id="content">
content
<br><br><br><br><br><br><br><br><br><br>test test
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
</div>
<div id="footer">
footer
</div>
<script type="text/javascript">
window.document.onscroll = function check1 (){
if (window.pageYOffset > 100)
document.getElementById("content").style.color = "lime";
if (window.pageYOffset < 100)
document.getElementById("content").style.color = "red";
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment