Solved

Javascript stack implementation

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now