简体   繁体   English

BlackBerry Webworks Navigation问题

[英]BlackBerry Webworks Navigation Issue

I have a index.html file with several onclick event handlers which redirect to other pages this way: 我有一个带有几个onclick事件处理程序的index.html文件,该处理程序以这种方式重定向到其他页面:

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) 因为否则该应用程序将在OS 6.0上退出(在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). 当我从page2.html返回index.html时,index.html中的所有onclick处理程序都起作用,除了重定向到我刚来自的页面(在本例中为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. 我尝试对onclick处理程序使用单独的函数,但发现确实触发了该函数,但其​​中的window.location函数却未执行。

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. 奇怪的是,使用触摸屏单击时会执行window.location函数,但不能使用触控板单击,并且仅在6.0中执行。 in 5.0 it works fine. 在5.0中可以正常工作。

any help would be appreciated 任何帮助,将不胜感激

Could you try changing your onclick to something like this (for debugging purposes) 您能否尝试将onclick更改为这样的内容(出于调试目的)

onclick=" try { window.location='page2.html'; } catch(e) { alert('error: ' + e); } " 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.. 查看bbUI.js如何做到这一点。

"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." “ bbUI工具箱以最优化的方式为目标操作系统构建了应用程序的UI。它遵循的方法是将一个屏幕作为HTML片段加载到其中的单个网页。每个屏幕都是其自己的HTML片段文件。然后,该工具包使用AJAX将屏幕推入和弹出堆栈。工具栏管理屏幕堆栈并加载内容。这确保了设备内存的最佳利用。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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