Solved

Javascript stack implementation

Posted on 1997-11-10
2
647 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…
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…

829 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