Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    browser history loses urls

    I've written my site so that bigger versions of images can be launched in a new 'viewer' window.
    This window stays open and accumulates the pictures which are chosen from the main page.
    I've written a simple javascript 'back' and 'forward' so that users can view the images collected in the viewer window.

    The problem:
    If you use the 'back' to go to previous pics, the history disappears.
    ie: you choose pics 1, 2, 3. You go backwards in the viewer window - 2, 1. You go into the main window and chose a other pic, 4. You want to see pics 2 & 3 again, so you click the back button, but the history for 2 & 3 has gone.

    Is this a history problem, or a browser problem, or a coding problem?

    Many thanks

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tamcole
    Is this a history problem, or a browser problem, or a coding problem?
    well, my crystal ball is on the blink today, so you'll have to post some code for me to help you. I presume others might think the same, too, not being privy to their psychic abilities either.
    *keep it simple (TM)

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    My crystal ball is getting these weird signals... They look somewhat like this:

    History:
    1. image 1
    > (User goes to next image)
    2. image 2
    > (User goes to next image)
    3. image 3
    > (User reverts to history location 1)
    1. image 1
    > (User goes to image 4)
    2. image 4 (this replaces the earlier forward history)

    If that explains what happens, you should also see why it behaves like it does. You're using the history for something it wasn't meant to do.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that's what happens. I had always had the impression (obviously hadn't looked carefully enough) that history recorded urls visited, in the order they were visited, and wiped addresses if they had moved further up the list -
    1 > 2 > 3 > 2 > 1 > 4 would result in a history of 4, 1, 2, 3.

    So, is there any simple way of not losing addresses? Looks like it had better be simple...

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,639
    Thanks
    0
    Thanked 649 Times in 639 Posts
    The only way to not lose those visits would be to keep count of how many back button presses had occurred and go forward that far in history before loading the next page (and zeroing the back count).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Tamcole: Navigation and history are separate - if a user navigates somewhere, it's added as the next item in history, replacing any previous forward history from that point. Moving from one point in the history to another on the other hand doesn't change anything in the history itself. As felgall said, the only way to get around this would be to store the number of history jumps you've been doing. And that would break any user using the browser history UI instead of your JavaScript UI.

    Trying to illustrate this:
    Code:
        1       2       3       4
    1:IMAGE1
    2:image1  IMAGE2
    3:image1  image2  IMAGE3
    1:IMAGE1  image2  image3
    2:image1  IMAGE4
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •