二、实现从一页面跳转到指定模块的位置,并将该模块在主区域中显示出来


1、跳转指定页面一般使用如下代码
<a href="weixin.html#person" class="back" id="back-person"></a>
但跳转时显示“微信”模块且导航中“微信”按钮点亮。
2、为了在主区域显示出要跳转到的指定person模块,可以先获取当前的url中的hash,然后再隐藏其他模块
 
   

function jumpToCurPage() {
if (!document.getElementById) return false;
if (!document.getElementsByTagName) return false;
if (!document.getElementsByClassName) return false;
var locationHash = window.location.hash.split("#")[1];

selectNav(locationHash);
showSection(locationHash);
return false;
}

其中selectNav()和showSection()两个函数和上一篇文章里面的代码一样

猜你喜欢

转载自blog.csdn.net/abcwangruili/article/details/77411623