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
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
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.
i need something like the browers do
example if no history it will disable the button
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
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.
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
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