简体   繁体   中英

How to add custom history in HTML5 to prevent android back button to display just previous view in cordova application?

I created an application with help of http://coenraets.org/blog/cordova-phonegap-3-tutorial/ . When I click on the SMS link in the Employee details view it opens native message composer because the link's is as href="sms:6170000010" , but when I click on the Android back button while message composer is opened it takes the application to previous view something like window.history.back() , but I want only to close message composer. How can I customise my source code to only close the message composer when back button is pressed for this particular situation and for rest of the application should behave as it is?

Below is Employee details view screenshot:

在此处输入图片说明

I Fixed it using HTML5 History pushState function.This allow me to add history entry in History Array. So on android back button click will pop current(smsComposer) view from the history array and employee details view will be as it is.

<a href="sms:6170000010" onClick="modifyBrowserHistory()" >    

    function  modifyBrowserHistory(){
            window.history.pushState({page:"smsComposer"},"sms composer");

    }

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