HTMLViewer back / forward buttons?

Hi,
I would like to include back and forward buttons to use with my HTMLViewer control.

What is the most efficient way of achieving this?
My idea is this:

Create an array which adds any new URLs to the array, upon URL change.
Then have the HTMLViewer display the previous array value when the back button is pressed; or the next array value when the forward button is pressed.

Is this the best way of achieving this, or is there a simpler method?

I have tried using the goBack and goForward properties, but they act erratic when URLs are selected via a PopupMenu.

Basically, if you select PopupMenu option 1, then option 2, then option 3 - the back button cycles back through all 3 URLs as expected. HOWEVER, if you once again select an option from the PopupMenu - the back button only allows me to go back 1 page?

Thanks.

the HTMLViewer has already the goBack and goForward commands

 Giulio

Using @Jason King 's ExecuteJavaScript extension to iOSHTMLViewer, I am using

dim t as text = HTMLViewer1.ExecuteJavaScript("window.history.back();")

and letting WebKit keep track of the history.

Sorry, didn’t realize that this was in OSX section. Having just worked on a project using this for iOS, the topic was fresh on my mind.

Same should apply for OSX though, only that desktop has ExecuteJavaScript built into the standard HTMLViewer.

HTMLViewer1.ExecuteJavaScript("window.history.back();") HTMLViewer1.ExecuteJavaScript("window.history.forward();")

Unless you want to present a menu of the links.

Seems that I was looking for a difficult solution to an easy problem.

Hmm - it seems that all of these solutions do the same thing :frowning:

  1. I select PopupMenu1 option 1 (page1 loads)
  2. I then select PopupMenu1 option 2 (page2 loads)
  3. I then press the back button (page1 reloads)
  4. I then select PopupMenu1 option 3 (page3 loads)

NOW - I can only go back 1 page???

Is that expected?
I would expect to be able to cycle back (page1, page2, page1), as in every browser.

Thanks.

If you are supplying the url from outside of the htmlviewer, the htmlviewer is starting fresh and is not building up a history for the default goBack and goForward commands.

Navigating links within the htmlviewer, you would have pages to go back/forward to.

So basically it is because I am using PopupMenu selections to navigate to the pages :frowning:

Don’t understand…
if I go to webpage 1, then webpage 2, and then webpage three
then back goes to webpage 2,
and back again goes to webpage 1
also if the url is supplyed with loadUrl
all is working for me ( at least on OS X )

Giulio - I think you misread my post.
You seem to have missed out step 3 :slight_smile:

  1. I select PopupMenu1 option 1 (page1 loads)
  2. I then select PopupMenu1 option 2 (page2 loads)
  3. I then press the back button (page1 reloads)
  4. I then select PopupMenu1 option 3 (page3 loads)

NOW - I can only go back 1 page???

Scott has explained that it is due to using a PopupMenu for navigation, as opposed to using the HTMLViewer directly ;(

and then what happens?

You are right, I just made a test app and was able to loadURL from outside of the HTMLViewer to a few different sites and use goBack and goFarward to navigate between all of the loaded pages.

Try having just a PopupMenu, the HTMLViewer, and the back / forward buttons.

Then try this sequence of events:

  1. Select PopupMenu1 option 1 (page1 loads)
  2. Select PopupMenu1 option 2 (page2 loads)
  3. Press the back button (page1 reloads)
  4. Select PopupMenu1 option 3 (page3 loads)

You should then see what I mean - the back button refuses to cycle through the exact order the pages were viewed.

  1. I see page1
  2. I see page 2
  3. I go back to see page 1
  4. I see page 3

I’m sorry, but really can’t understand where is the problem :slight_smile:

Yes - now go back and you will see that you cannot go back to page 2.
You can only revisit page1 and page 3.

[quote=193245:@Richard Summers]NOW - I can only go back 1 page???

Is that expected?
I would expect to be able to cycle back (page1, page2, page1), as in every browser.[/quote]
In my browser, I can go back and forward the current path of sites that I have visited.

But, if I use the back button until I am in the middle of the list and I then change to a different link, I lose the newer sites for navigating back/forward. This is what I would expect. I changed course part way through, it would not save both paths.

All of the pages that I visit are in my history menu, just not accessible via back/forward buttons.

but that’s exactly how the browser history works:

try to repeat the steps in Safari or Firefox

type an url ad go to page 1
type an url ad go to page 2
press the Safari Back button and go back to page 1
type an url ad go to page 3
press the Safari Back button and you are again in page 1

Hmmmm - time for a break and a cup of tea.
I will come back to this later :slight_smile:

Thanks guys - much appreciated.

OKKEY :slight_smile:
let’s rewind this thread :slight_smile:
you want to handle the history, but on a different way that a browser does…
goBack and goForward function exactly as intended but you don’t want this

but that opens other big questions,

let’s say:
1 you are in page 1
2 you go to page two
3 you go back to page 1
4 you go to page 3
5 you go back again to page 1
NOW a forward button where should go? to page 2 or page 3?
if you can go back and forward,
but is some points of the history you fork in different direction, how can you handle this?

( Hope this was clear )

Ok - my back / forward buttons are doing the same as Safari - so I will keep what I have, as that seems to be the norm.

If I visited pages 1, 2, 1, 3
I would have expected the back button to go from 3, back to 1, then back to 2, then back to 1 (reverse order).
But it seems that going from 3, back to 1, then stopping, is the norm - so I will stick with that.

My head hurts :slight_smile: