Creating a back button

  1. 5 years ago

    Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    I want to add a button to my web pages to take the user back to the page they came from. I have tried to implement a form of tracking which page was the previous page but it doesnt work (my bad coding) and I was wondering if Xojo had any built in facility to access the page stack or some other clever way.

  2. Sascha S

    6 Jun 2014 Pre-Release Testers, Xojo Pro Germany
    Edited 5 years ago

    Why not simply use HTML code for this?

    <FORM><INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;"></FORM>

    Source: http://www.computerhope.com/issues/ch000317.htm

  3. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    I dont think that works because Xojo WE only has one actual page and everything else is loaded dynamically into that page.

    This is why you need to have some type of internal history to be able to do a "zzz.show" to reshow the page (using implicit instance).

    Their must be a way of cycling though the session page history and storing the name into a webpage object and then doing a show using that object.

  4. Albin K

    6 Jun 2014 Europe (Sweden)

    Keep the page index in an array and step back and forth in it and use Session.PageAtIndex ?

  5. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    How would you then show that page then?

  6. Albin K

    6 Jun 2014 Europe (Sweden)
    Edited 5 years ago

    Session.PageAtIndex(index).Show
    I have not tried this though.
    Theres also PageWithName and PageWithID that I "think" you might be able to use :)

  7. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    That sounds like exactly what I was after, thanks.

  8. Christian S

    6 Jun 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    Well, why not keep an array in the session of pages visited?
    When you go to new page, put it on the stack and when you want to go back, pick the top one.

  9. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    Ok but I am struggling with what type of array, can you have an array of type webpage? So could I then do something like:

    myWebpages(myWebpages.Ubound - 1).show
  10. Michel B

    6 Jun 2014 Pre-Release Testers RubberViews.com

    @Nathan W can you have an array of type webpage

    Yes. Dim mypages(n) as webpage

  11. Christian S

    6 Jun 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    you can have array of webpage.

    Add:
    session.webpages.append webpage1

    and go back
    dim pages() as webpage = session.webpages
    if pages.ubound >= 0 then
    dim p as webpage = pages.pop
    p.show
    else
    // ?
    end if

  12. David C

    6 Jun 2014 Pre-Release Testers, Xojo Pro Derby, ITM

    I have a generic report module I wrote in Web Edition which can be called from any Window from any app. I pass the report WebPage the current WebPage to a Property, so if they click the Back button it looks to see if that BackPage <> nil and if so, it shows it.

  13. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    @ChristianSchmitz dim p as webpage = pages.pop

    What does ".pop" do?

  14. Beatrix W

    6 Jun 2014 Pre-Release Testers Europe (Germany)

    A pop returns the last element of the array and then removes it.

  15. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    I never knew you could do that, I have always done it manually.

  16. Hamish S

    6 Jun 2014 Europe (Cambridge, UK)

    Remember that a good Back button will have a companion Forward button, so you should keep a forward stack as well, of pages which have been popped, so you can go forward to them. The usual way to do things is to then clear that array when the user clicks on anything other than the Forward button.

  17. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    @HamishSymington good Back button will have a companion Forward button

    Thanks for the suggestion but for what I am doing it is simply to take a user from a details page back to the page that has a listbox on it. The thing is that I have a number of pages that use said details page and this will increase so I wanted an easy way to have a generic back button the details page to take the user back to the page that they came from with the listbox on.

  18. Hamish S

    6 Jun 2014 Europe (Cambridge, UK)

    OK, no problem. Given that the back/forward paradigm is well understood by people, I'd suggest naming it something other than plain 'back' - i.e. 'back to the list', or a button with a little icon of a list, or something like that.
    H

  19. Nathan W

    6 Jun 2014 Pre-Release Testers, Xojo Pro Europe (UK, Jersey)

    @HamishSymington I'd suggest naming it something other than plain 'back'

    Yes thats a good idea, have changed it to "Back to List"

  20. 2 months ago

    Simon P

    Jan 11 Quebec, Canada

    @ChristianSchmitz you can have array of webpage.

    Add:
    session.webpages.append webpage1

    and go back
    dim pages() as webpage = session.webpages
    if pages.ubound >= 0 then
    dim p as webpage = pages.pop
    p.show
    else
    // ?
    end if

    Any idea the reason I am ending up with a blank page with the name of the project at the top left corner?

or Sign Up to reply!