Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

Javascript check page

Hi I'm wondering if i have many page for example 1.html, 2.html etc is there a way in JScript to check if they have visited every page?
0
bobby101
Asked:
bobby101
  • 3
  • 2
2 Solutions
 
Gurvinder Pal SinghCommented:
when ever you visit that page, create a cookie for that page. something like
pageExample1Visited=true;

So you can check if a cookie exists for a page, that means it is visited.
0
 
bobby101Author Commented:
new to JScript, please explain in depth
0
 
Gurvinder Pal SinghCommented:
Sure,
1) when you visit a page, check for the existence of a cookie for that page.
http://plugins.jquery.com/project/Cookie
Say you have visited Page1.html, so you will check for the existence of cookie 'Page1FirstCookie'.
2) If the cookie exists, it means it is not your first visit.
If the cookie doesn't exists, that means this is your first visit to this page. So you need to create this cookie now, so that next time you visit here, you can check if the cookies exists or not.

Let me know if this doesn't help


0
 
Gurvinder Pal SinghCommented:
@bobby101: please let me know if your problem is resolved.
0
 
bobby101Author Commented:
got it to wrk
function checkPages(div) {
	var div = document.getElementById(divId);
	
	page1 = getCookie('page1');
	page2 = getCookie('page2');
if (page1 == 'visited' && page2 == 'visited'){
		div.innerHTML = 'All pages visited, you can advance to <a href="example.html">next</a>';
		
	} else {	
		div.innerHTML = "Please visit all pages before continuing.";
	}
}

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now