Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 6
Registered: ‎05-26-2009
My Device: Torch 9810/Playbook
My Carrier: Rogers

onunload event doesn't fire

[ Edited ]

Has anyone been able to get the onunload to fire when the user closes the browser or navigates to a different page?  Here's some very basic html to test out the onload and onunload.  The onload works fine however nothing seems to happen for the onunload.

 

This was seen on the Blackberry Bold (4.6.0.150) simulator.

 

Sample source:

<html> <head> <title>Test onload/onunload</title> <meta name="HandheldFriendly" content="true" /> <meta http-equiv="CACHE-CONTROL" content="NO-CACHE" /> <meta http-equiv="PRAGMA" content="NO-CACHE" /> <meta http-equiv="EXPIRES" content="-1" /> </head> <body onload="alert('onload...')" onunload="alert('unloading..');" > Test page </body> </html>

 

Any help would be appreciated.

 

TIA.

Message Edited by Dimentox on 07-07-2009 06:18 PM
New Member
Posts: 1
Registered: ‎03-01-2010
My Device: Bold 9000
My Carrier: AT&T

Re: onunload event doesn't fire

Well.  It's been awhile since your post, but it seems the issue is still around.  I have a Bold 9000 and the onunload event seems to never fire.  I've tried various scripting methods to try to get a response out of the Blackberry browser when switching pages, but I just can't get the onunload event to come to life.

 

Is this a known issue?

Thanks.

Developer
Posts: 124
Registered: ‎09-06-2010
My Device: Not Specified

Re: onunload event doesn't fire

What eam2nd said. 

 

Anyone ever get onunload to fire using the BB browser?  It's not working for me on a 9550. 

 

I don't care if it was a rain dance, if you have a trick to make onunload fire, I want to hear it.

 

(onunload is firing just fine for me on the Torch browser.)

 

 

 

 

 

Developer
Posts: 124
Registered: ‎09-06-2010
My Device: Not Specified

Re: onunload event doesn't fire

It bothers me that no one seems to be interested in this.  BB browser docs say unload event is supported, but I found the following on the BB issue tracker:

 

https://www.blackberry.com/jira/browse/WEBAPI-25

08/Dec/2009
Alon,

Thank you for taking the time to submit this issue. The unload event is not supported by the BlackBerry browser.

I have submitted a Feature Enhancement request to include this feature in a future version of the browser application.

Unfortunately there is also an error in our documentation, where the unload event is listed as a supported feature. I am also following up with our technical documentation team to correct these docs and reduce any future confusion.

Sincerely,
Adam Stanley

 

That was a year ago.  The documentation still says it's supported. 

 

I will continue to keep this thread alive until I post a solution, or someone from RIM steps up.

Developer
Posts: 124
Registered: ‎09-06-2010
My Device: Not Specified

Re: onunload event doesn't fire

Despite knowing it wouldn't work, I had to try to grab the BrowserField from my WebWorks JavaScript extension and see if I could catch the documentUnloading event using a BrowserFieldListener.

 

 

extension class:

public void register(WidgetConfig widgetConfig, BrowserField browserField) {
browserField.addListener( new BrowserFieldListener() {
public void documentLoaded(BrowserField browserField, Document document) {
Logger.log("documentLoaded");
}
public void documentUnloading(BrowserField browserField, Document document) {
Logger.log("documentUnloading");
}
});

 

 

documentLoaded is invoked.

 

documentUnloading is not. Smiley Mad