Solved

Javascript stack implementation

Posted on 1997-11-10
2
652 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

696 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