1

If a user clicks a link from inside Facebook native iOS or Android app, the default is that a webview is opened inside the FB app instead of the regular browser. Is there a way to ask a user whether to leave or not when they try to close the webview?

In regular browsers, it's done like with javascript:

<script type="text/javascript">
 var popit = true;
 window.onbeforeunload = function() { 
      if(popit == true) {
           popit = false;
           return "Are you sure you want to leave?"; 
      }
 }
</script>

This does nothing in the in-app browser. Is there an equivalent that works? Note: I'm talking about website not mobile apps.

Michael Samuel
  • 3,820
  • 12
  • 45
  • 85
  • check here --> i assume you mean when they press the back button, if so its just a case of alerting the user on onBackPressed() -- this is for Android http://stackoverflow.com/questions/2257963/how-to-show-a-dialog-to-confirm-that-the-user-wishes-to-exit-an-android-activity – Tasos Aug 27 '16 at 21:59
  • Remember I'm talking about websites not mobile apps. This event I assume is for android development – Michael Samuel Aug 27 '16 at 22:04
  • the way FB works is that when a user clicks a link a webview activity is started passing the url to it. and loads the page. what exactly are you after then ?? – Tasos Aug 27 '16 at 22:09
  • I want to detect the closing of the in-app browser using web javascript in both android and ios – Michael Samuel Aug 27 '16 at 22:27
  • i see. You want a confirmation alert before closing a tab with your website on mobile browsers. Dont think that possible. People would just close the browser anyway if they saw such an alert – Tasos Aug 27 '16 at 22:38

0 Answers0