简体   繁体   中英

BlackBerry Webworks Navigation Issue

I have a index.html file with several onclick event handlers which redirect to other pages this way:

onclick="window.location='page2.html';"

I am handling the back button with

blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, function() { 
        window.history.go(-1);
        return false;
    }); 

Because otherwise the app exits on OS 6.0 (no need for it in 5.0)

when i go back to index.html from page2.html, all the onclick handlers in index.html work except the one that redirects to the page i just came from(in this case page2.html). I tried using a separate function for the onclick handlers, and found out that it does get triggered, but the window.location function inside it doesnt get executed.

The strange thing is that the window.location function gets executed when clicking with a touchscreen, but not with the trackpad, and only in 6.0. in 5.0 it works fine.

any help would be appreciated

Could you try changing your onclick to something like this (for debugging purposes)

onclick=" try { window.location='page2.html'; } catch(e) { alert('error: ' + e); } "

If it there is a runtime error occurring then it should alert you.

On a side note, I'm a little concerned with that technique of changing pages/content in your app. If you don't implement this properly you risk running in to memory issues. Have you considered using any frameworks that handle loading/unloading page-fragments?

Check-out how bbUI.js does this..

"The bbUI toolkit builds the application's UI in the most optimized fashion for the target operating system. It follows a methodology of a single web page that has screens loaded into it as HTML fragments. Each screen is its own HTML fragment file. The toolkit then uses AJAX to push and pop screens off of the stack. The toolkilt manages the screen stack and loading the content. This ensures the best use of device memory."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM