android - Cordova - Trying to execute a function inside a webview -
i have webview website working in app. i'm trying asking users when hit android button if want leave app. i'm using inappbrowser plugin. here's code.
document.addeventlistener("deviceready", ondeviceready, false); // cordova ready function ondeviceready() { navigator.splashscreen.show(); var ref = window.open("http://m.estadao.com.br", "_self", "location=no"); ref.addeventlistener('loadstop', function(){ ref.executescript({ code: document.addeventlistener("backbutton", onbackkeydown, false); function onbackkeydown() { navigator.notification.confirm( "tem certeza que deseja sair?", function(buttonindex){ confirmexit(buttonindex); }, "aviso", "ok, cancel" ); } function confirmexit(stat){ if (stat == "1"){ navigator.app.exitapp(); } else { window.open("http://m.estadao.com.br", "_self", "location=no", "zoom=no"); } }; }); }); }
and here link of plugin http://cordova.apache.org/docs/en/2.7.0/cordova_inappbrowser_inappbrowser.md.html#executescript
any idea can make work ? thanks!
i assuming problem back-button event not getting triggered once webview loads. common problem using in-appbrowser plugin webview. loads page loose control on page. use following plugin https://github.com/wizcorp/phonegap-plugin-wizviewmanager/ webview. creates custom webview inside phonegap app , still have control on button , can define size of webview
Comments
Post a Comment