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 7 of 7

Thread: history.back()

  1. #1
    New to the CF scene
    Join Date
    May 2007
    Location
    Phil
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    history.back()

    what's the problem with the code below?
    in Opera, clicking the back button displays the submitted form along
    with the inputs.
    in Mozilla, the inputs are all gone...

    <input type="button" value="Go Back" onClick="window.self.history.back()" >

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Nothing is wrong with it persay. Browsers handle forms differently. Some keep the data, some don't. Firefox is one that doesn't unless you tell it to. Instead of this
    Code:
    <input type="button" value="Go Back" onClick="window.self.history.back()" >
    I would try
    Code:
    <input type="button" value="Go Back" onClick="history.go(-1)">
    That probably won't change anything but its shorter.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Nothing is wrong with it persay. Browsers handle forms differently. Some keep the data, some don't. Firefox is one that doesn't unless you tell it to. Instead of this
    Code:
    <input type="button" value="Go Back" onClick="window.self.history.back()" >
    I would try
    Code:
    <input type="button" value="Go Back" onclick="history.go(-1)">
    That probably won't change anything but its shorter.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New to the CF scene
    Join Date
    May 2007
    Location
    Phil
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but how can i retrieve the inputs? it is impt. that the submitted form (w/ the inputs) be displayed

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    To do that you need to use a browser that keeps the inputs.
    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
    There is no guarantee that forms ill be correctly filled when using the browser history - not in any browser. To solve that for all cases, you need to do it server side. Which you should probably be doing anyway, it's good form design.
    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

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adirondacks
    Posts
    516
    Thanks
    4
    Thanked 4 Times in 4 Posts
    I have no experience with it but yahoo yui has a nice browser history added to the library now.


  •  

    Posting Permissions

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