Following this Stack Overflow post, i am trying to make a div float as i scroll down the webpage but it's not working for me.
Below is the code snippet
<script type="text/javascript">
window.onscroll = function (e) {
var vertical_position = 0;
if (pageYOffset)//usual
vertical_position = pageYOffset;
else if (document.documentElement.clientHeight)
vertical_position = document.documentElement.scrollTop;
else if (document.body)
vertical_position = document.body.scrollTop;
var your_div = document.getElementById('menuDiv');
your_div.top = (vertical_position + 200) + 'px';
}
</script>