SoFunction
Updated on 2025-04-03

When scrolling to the top of the page, the instance code is fixed on the top


<body style="margin:0px;">
<div style="height:300px;background:#e0e0e0"></div>
<div style="background:#ffffff;width:100%;"><ul><li><a

href="/menu/net/" target="_blank">.NET</a></li>
<li><a href="/menu/javascript/" target="_blank">Javascript</a></li>
<li><a href="/menu/jquery/" target="_blank">jQuery</a></li>
<li><a href="/menu/csharp/" target="_blank">C#</a></li>
<li><a href="/menu/other/" target="_blank">Other</a></li>
<li><a href="/" target="_blank">Home</a></li></ul>
</div>
<div style="height:2600px;background:#999"></div>
<script type="text/javascript" src="/keleyi/pmedia/jquery-1.9."></script>
<script type="text/javascript">
$(function () {
var ie6 = ;
var dv = $('#fixedMenu_keleyi_com'), st;
('otop', ().top); //Storage the original distance from the top
$(window).scroll(function () {
st = ( || );
if (st > parseInt(('otop'))) {
if (ie6) {//IE6 does not support fixed attribute, so you can only achieve this effect by setting position to absolute and top
({ position: 'absolute', top: st });
}
else if (('position') != 'fixed') ({ 'position': 'fixed', top: 0 });
} else if (('position') != 'static') ({ 'position': 'static' });
});
});
</script>
</body>