简体   繁体   English

JavaScript帮助-带有Page事件/变量

[英]JavaScript Help - With Page event/Var

Can anyone help me with the following? 谁能在以下方面帮助我?

I have a navigation bar, for example: 我有一个导航栏,例如:

Step_1.html - Step_2.html - Step_3.html - Step_4.html Step_1.html-Step_2.html-Step_3.html-Step_4.html

i would like the links for the next two steps ie 3 and 4 to be disabled. 我想禁用接下来的两个步骤(即3和4)的链接。

Then when they go to step 2 only step 4 to be disabled. 然后,当他们转到步骤2时,仅禁用步骤4。

(but heres the problem when i get to say Step_4.html and want to go back to Step_2.html, i want to be able to click straight back to Step_4.html as i have been through all the steps already so i would like it to now not be disabled in my navigation bar) (但是当我说Step_4.html并想回到Step_2.html时,这就是问题,我希望能够直接单击回到Step_4.html,因为我已经完成了所有步骤,所以我很喜欢现在不会在我的导航栏中被禁用)

I would only like to use java-script if possible ! 如果可能,我只想使用Java脚本!

Page 1 looks like this: 第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>

Page 2 like this 像这样的第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>

page 3 like this 像这样的第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>&nbsp;</p>
</body>
</html>

page 4 like this 像这样的第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>

You are going to want to use cookies created in javascript to store the state of where they are in the step-by-step process. 您将要使用在javascript中创建的cookie来存储它们在逐步过程中的状态。

Check out http://www.w3schools.com/js/js_cookies.asp 查看http://www.w3schools.com/js/js_cookies.asp

Make a cookie that stores the highest step the user has gotten to. 制作一个cookie,存储用户已达到的最高步骤。 Check the value of this on each page, and if the page they are on is "higher" (step 4 > step 3), overwrite the cookie with this new value. 在每个页面上检查此值,如果它们所在的页面“较高”(步骤4>步骤3),则用此新值覆盖cookie。 That way, if they back up to step 1 from step 4, they will still have "access" to step 4. 这样,如果他们从步骤4备份到步骤1,他们仍然可以“访问”步骤4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM