Languages

Menu
Sites
Language
Using Back Key (hardware key) to close web browser

I have a web app that views external website. This is not a problem. However, when the browser is opened I am unable to use the "Back" hardware key in the simulator to close the browser to return to the app.  I have tried to assign a listner to the browser app but with no success. I am able to use the below listed code to successfully use the "Back" button throughout my app but it doesn't work for the browser.

[IMPORTANT] Is there any way to assign an Event Listner to the browser app so that when the "Back" key is pressed it will close (exit) the browser?

 

document.addEventListener( 'tizenhwkey', function(e) {
 
if (e.keyName === 'back') {
if ($.mobile.activePage.attr('id') === 'indexJump') {
tizen.application.getCurrentApplication().exit();
} else {
history.back();
}
}
 
});
 
Thanks,
Ethan-Anthony
Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

11 Replies
konduri sai swathi
Hi, Try launching browser using application control using below code :
function open_browser(){
var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view","http://tizen.org", null, null, null);
tizen.application.launchAppControl(appControl, null, function() {console.log("launch application control succeed"); },
function(e) {console.log("launch application control failed. reason:" + e.message); },null );
}
html code :
<a onclick="open_browser()">Tizen</a>
Replace "http://tizen.org" in the app control with the url you want to open.
konduri sai swathi
Also add application.launch privilege.
Ethan Wade
Thanks Konduri, Unfortunately I tried your suggestion but it did not work. Privileges were properly set etc. I am on Tizen 2.2. Can't get the hardware back button to work for the browser. I am using the simulator. Thx
youngsik yoon
as far as i know, default browser is closed by hw back key. so i think you should try it in emulator or reference device.
Ethan Wade
Thank you for the reply. I figured as much. :) The only challenge I'm faced with is that my emulator (Tizen 2.2 on Mac OSX) gets stuck on the boot screen. :( It would be nice to have a reference device. My app is completely done but I keep getting rejected by the store because when they test it on a device (eg I have a link to an external web page within the app which opens the page in a browser) the back button doesn't work. I have tried everything under the sun. :) The strange thing is that the browser which opens doesn't have an location or anything (like the default Tizen browser). It's just a full browser page. This is ok with me, as I just want to be able to close the browser with the default back button.
Maksym
Default browser works fine separetelly, but if a hyperlink opened from tizen web application than browser is opened but no possibility to go back. Task switcher does not show that the browser is opened. history.back() does not work too
Ethan Wade
Thank you for the insight Maksym. Much appreciated. :)
Alexander AVSukhov
Hi, This is not related to Internet application. When link is clicked it is opened in the same application (own web control). As new page is getting launched in the same window and document is overwritten, hence 'tizenhwkey' event is not handled. Please check again using task manager. To display page in your application, use iframe inside the content div or use Application Control to launch Internet app.
Maksym
The question is still actual: What is the way to exit from browsing a page opened from application?
Marco Buettner
On the simulator you have another working of the procedur like on the emulator or device. Test you application on the EMULATOR to get the real envoriment. The simulator isn't a 100% tizen envoriment :)
Maksym
It is on emulator