Solved

Javascript stack implementation

Posted on 1997-11-10
2
635 Views
Last Modified: 2012-08-13
  I know this is probably very simple but has anyone implemented a stack, with push and pop capabilities, using Javascript? I need an example to use to keep track of URLs visited on my site and allow a user to back out the way they came in. I know about the History.back and history.go functions but IE and Netscape implement them differently in pages utilizing frames.
0
Comment
Question by:gwolf111097
2 Comments
 
LVL 6

Accepted Solution

by:
tecbuilder earned 100 total points
ID: 1273328
If your web site is not all frames then you will have to resort to using cookies or opening a window and use the methodology described below.  Only problem is if the user closes the window.

If your web site is frames only then you can store where the user has been or is going in one of the frames that don't change.  To implement create a global array and counter variable in the non-changing frame.  Then when the user goes from one URL to another you call a function that increases the counter and then inserts the URL to where they are going into the array at the counter location.

function addURL(toURL) {
  cntURL = cntURL + 1
  arrayURL[cntURL] = toURL
}

To go back:

function gotoURL() {
  cntURL = cntURL - 1
  parent.yourframename.location = arrayURL[cntURL]
}

0
 

Author Comment

by:gwolf111097
ID: 1273329
While not having a pop function, this works for me. Thanks!

   
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show confirmation alert in Jquery 14 38
rhino JavaScript import, load 25 66
MacOS and programming in React 7 27
Interview question Javascript, database 12 25
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

919 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

14 Experts available now in Live!

Get 1:1 Help Now