Results 1 to 7 of 7

Thread: back and forward button

  1. #1
    Join Date
    Jul 2007
    Posts
    59
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default back and forward button

    How can i make Back and forward button with the image that can detect history if no history will disable the button some thing like browers

    thank

  2. #2
    Join Date
    Aug 2006
    Posts
    30
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Your options are kinda limited.

    history.back() or history.go(-1)
    history.foward() or history.go(1)
    history.length


    history.length seems like a ray of hope... but its not.
    if you start at page1.htm navigate to page2.htm then back to page1.htm it will only show 2 items in the history list. There is also no history index to reference to see where you are in the list. history[0] will not say page1.htm it will throw an error.

  3. #3
    Join Date
    Jul 2007
    Posts
    59
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    i need something like the browers do
    example if no history it will disable the button

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    if (history.length !> 1)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Aug 2006
    Posts
    30
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    With that the button will never disable once you have been to 2 webpages.
    Even if you go back to the first page it will still say there are 2 items in the history.

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, that was the simplest answer.

    You should/could combine this with a check to find which history item the current page matches.... anyway.... seems a bit awkward.

    Here's my LOGIC, as psuedo-code:
    Code:
    if (current != history.veryfirst) { //ok; }
    //check for the first history item, and gray out the back button if it's equal to this.
    if (current != history.verylast) { //ok; }
    //check for the last page, to be sure the forward button can be valid; if not, gray it out.
    if (history.length>0) { //ok; }
    //be sure that the length is at least two items, then you know you have one valid option, at least.
    //If not, gray out BOTH buttons (if it's 1 or more, you can let the code above handle making it gray for 1 or 2 matches)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    But, the history object is not accessible in that manner (for security reasons). The browser has a back and forward button, use them. Save your coding expertise for something that the browser doesn't have.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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