Solved

Javascript check page

Posted on 2010-09-24
5
280 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
Comment Utility
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
Comment Utility
new to JScript, please explain in depth
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 500 total points
Comment Utility
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
Comment Utility
@bobby101: please let me know if your problem is resolved.
0
 
LVL 4

Author Comment

by:bobby101
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now