有人可以帮我解决以下问题吗?
我有一个导航栏,例如:
Step_1.html - Step_2.html - Step_3.html - Step_4.html
我希望禁用接下来两个步骤(即 3 和 4)的链接。
然后,当他们转到步骤 2 时,只有步骤 4 被禁用。
(但是当我说 Step_4.html 并想要返回 Step_2.html 时,问题就来了,我希望能够直接单击回到 Step_4.html,因为我已经完成了所有步骤,所以我希望现在不在我的导航栏中禁用它)
如果可能的话,我只想使用java脚本!
第 1 页如下所示:
<!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>
<script type="text/javascript" src="sessvars.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>p4</title>
</head>
<body>
<p>Page 1</p>
<p><a href="p2.html">Page 2</a></p>
<p>Page 3</p>
<p>Page 4</p>
</body>
</html>
第 2 页是这样的
<!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>
<script type="text/javascript" src="sessvars.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>p4</title>
</head>
<body>
<p><a href="p1.html">Page 1</a></p>
<p>Page 2</p>
<p><a href="p3.html">Page 3</a></p>
<p>Page 4</p>
</body>
</html>
第 3 页是这样的
<!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>
<script type="text/javascript" src="sessvars.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>p4</title>
</head>
<body>
<p><a href="p1.html">Page 1</a></p>
<p><a href="p2.html">Page 2</a></p>
<p>Page 3</p>
<p><a href="p4.html">Page 4</a></p>
<p> </p>
</body>
</html>
第 4 页是这样的
<!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>
<script type="text/javascript" src="sessvars.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>p4</title>
</head>
<body>
<p><a href="p1.html">Page 1</a></p>
<p><a href="p2.html">Page 2</a></p>
<p><a href="p3.html">Page 3</a></p>
<p>Page 4</p>
</body>
</html>
最佳答案
您将需要使用在 javascript 中创建的 cookie 来存储它们在分步过程中所处的状态。
查看http://www.w3schools.com/js/js_cookies.asp
制作一个 cookie 来存储用户已达到的最高步数。检查每个页面上的此值,如果它们所在的页面“更高”(步骤 4 > 步骤 3),则使用此新值覆盖 cookie。这样,如果他们从步骤 4 备份到步骤 1,他们仍然可以“访问”步骤 4。
关于JavaScript 帮助 - 使用页面事件/Var,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9359980/