I’m on the team working on Pylon, a smartphone app which allows the user to approve Nintex tasks, among other things. It currently uses BlackBerry Webworks, which is a platform that uses HTML and JavaScript in the UI. On one screen we wanted functionality that would send the user back to the previous screen (as if they clicked the back button). The way to do this in JavaScript is:
history.go(- 1 );
|
or
history.back(); |
However, in my testing this did nothing on the BlackBerry Torch running OS 6, or on the Torch simulator. I found a workaround which works on most OS 5 and 6 devices (see Caveat for the exception.)
Basically, I needed to write a Webworks extension function to trigger the behavior from Webworks. There was a fair amount of the figuring out how that would work, but the end result is fairly simple. The Webworks extension exposes a BrowserField object. Webworks runs as native BlackBerry application with a BrowserField widget where the HTML and JavaScript are rendered. The method BrowserField.back() can be used to trigger the Webworks application to go back once, and this worked fine on the Torch.
The basic steps to workaround were:
- Write a new extension function so that the JavaScript code could call it. I named this goBack().
- Store BrowserField when we get it from the Webworks framework
- When goBack() is called, call BrowserField.getHistory().canGoBack(), and if that returned true, call BrowserField.back()
Share the post "Working around history.back() bug in BlackBerry Torch browser widget"