window.onload=function(){ //a.html#2 var hash=window.location.hash; alert(hash.split('#')[1]);//2 }
var hash; hash=(!window.location.hash)?"#search":window.location.hash; window.location.hash=hash; //调整地址栏地址,使前进、后退按钮能使用 switch(hash){ case "1": //显示任务流程 break; case "2": //常见问题 break; case "3": //相关链接 break;
<head>
</head>
<body>
<a href="b.html?index=1">任务流程</a>
<a href="b.html?index=2">常见问题</a>
<a href="b.html?index=3">相关链接</a><script type="text/javascript">
</script>
</body>
</html>b.html
<!DOCTYPE html PUBliC "-//W3C//dtD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/dtD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script type="text/javascript"> window.onload = function(){
var url = location.search; //获取url中"?"符后的字串
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var index = str.split("=")[1] - 1;
document.getElementsByTagName('a')[index].style.display = 'block';
}
}
</script><body>
<a href="b.html?index=1" style="display:none">任务流程</a>
<a href="b.html?index=2" style="display:none">常见问题</a>
<a href="b.html?index=3" style="display:none">相关链接</a></body>
</html>
在a.html中点击任务流程之后跳转的b.html页面中,任务流程和对应的内容是显示的这个是a.html页面中的
<li>
<div class="foot_L"> <a href="<{$url_back_to_offers}>&type=-9#step" target="_blank"> </a> </div>
<div class="foot_R"> <a href="<{$url_back_to_offers}>&type=-9#step" target="_blank"> </a>
<p>教你如何完成任务</p>
</div>
</li>
<li>
<div class="foot_L how_L"> <a href="<{$url_back_to_offers}>&type=-9#problem" target="_blank"> </a> </div>
<div class="foot_R how_R"> <a href="<{$url_back_to_offers}>&type=-9#problem" target="_blank"> </a>
<p>为你解惑答疑</p>
</div>
</li>
b.html<li class="li_cur"><a href="#problem">常见问题</a></li>
<li><a href="#step">任务流程</a></li>
<li><a href="#link">关于我们</a></li>
//a.html#2
var hash=window.location.hash;
alert(hash.split('#')[1]);//2
}
hash=(!window.location.hash)?"#search":window.location.hash;
window.location.hash=hash;
//调整地址栏地址,使前进、后退按钮能使用
switch(hash){
case "1":
//显示任务流程
break;
case "2":
//常见问题
break;
case "3":
//相关链接
break;
}