views:

39

answers:

2

Unless I'm being completely blind there appear to be no methods implemented in the WebBrowser class on Windows Phone 7 to navigate backwards and forwards through the pages within the browser, nor refresh the existing page?

Am I right in this assumption? Can this be achieved another way?

I have tried using "javascript:history.go(-1)" as a URI and asking the WebBrowser object to navigate to it, but that didn't do anything.

A: 

It has the Navigate methods from its parent class, those don't do what you need? Otherwise you could use NavigationService to do the navigation back?

Or are you only trying to navigate the browser from inside javascript inside the browser?

John Gardner
I am creating a web browser view within my app rather than backgrounding the app and using Internet Explorer so some application tasks can continue to run whilst the user is in the browser view. I can see no way of implementing 'Back' and 'Forward' buttons on this view to control the users navigation in the embedded WebBrowser object. Navigate methods such as .GoBack() etc. don't work.
andybee
ah, since those would navigate YOUR page back off the stack instead of the browsers... interesting.
John Gardner
Indeed. It seems a very... unusual oversight.
andybee
A: 

You're right, WebBrowser doesn't have back/forward/refresh methods. You need to InvokeScript into javascript and do it from there. InvokeScript works best with pre-defined javascript functions you've defined on the page. Sometimes you can do something like this: webBrowser.InvokeScript("eval", "history.go(-1)"). However that's not always guaranteed to work since eval will not work if the page has no tags or if eval has been overriden by other script.

Skeets