discuz 门户页面支持导航顶部固定

discuz教程
目录 网上的方法,在需要顶部固定的页面加一句代码:<!--{if empty($_G['setting']['disfixednv_forumindex']) }--><script>fixed_top_nv();</script><!--{/if}-->复制代码亲测此方法成功过,也失败过。如果不管用,也可以使用下面代码:

<style type="text/css">.floatnv{position:fixed;_position:absolute;top:0px;z-index:999;width:100%;}</style><script language="javascript" type="text/javascript"> (function() { var oDiv = document.getElementById("nv"); var H = 0, iE6; var Y = oDiv; while (Y) { H += Y.offsetTop; Y = Y.offsetParent; }; iE6 = window.ActiveXObject && !window.XMLHttpRequest; if (!iE6) { window.onscroll = function() { var s = document.body.scrollTop || document.documentElement.scrollTop; if (s > H) { oDiv.className = "floatnv"; if (iE6) { oDiv.style.top = (s - H) + "px"; } } else { oDiv.className = ""; } } } })();</script>

document.getElementById("nv");对应的是id="nv"的元素。

标签: