Solved

Javascript check page

Posted on 2010-09-24
5
282 Views
Last Modified: 2012-05-10
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
Comment
Question by:bobby101
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 33752523
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
 
LVL 4

Author Comment

by:bobby101
ID: 33752722
new to JScript, please explain in depth
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 500 total points
ID: 33752862
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
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33786424
@bobby101: please let me know if your problem is resolved.
0
 
LVL 4

Author Comment

by:bobby101
ID: 33787509
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Is there a way to use PhantomJS on a shared server? 4 17
JavaScript let vs var 5 27
powershell script 9 26
Multiflying 2 Input Text On a Table 7 21
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question