3

I am new to angularjs , so this question might seems silly to experience ones , But i really not able to perform this , can any body tell me that how to come back to app from webview after reaching to specific url , Like i am opening a window in browser for payment process so what i need is that when url in webview comes up with a success msg , i want to close the webview and get back to my application , I goggled and found a way that in $window.open() we pass three parameters and through second i can do that , but don't know how to implement that , can any one provide me a way to deal that.

i studied thi link :- Tracking a child window across page loads

i tried this function too :-

 if (!$window.closed){ 
 if($window.location.href =="http://www.magentomobileshop.com/demo/index.php/payu/index/success")
 {
    $window.close()
   }
                 
 } 

Thanks

Community
  • 1
  • 1
user2028
  • 163
  • 4
  • 15
  • 40

2 Answers2

2

Please have a look on it :- Close a child window in an Android app made with Angularjs

here is my updated Answer ...and I have tested it and its working fine

var url = "test_Url";

var socialLoginWindow = window
  .open(url,
    '_blank',
    'location=no');
// listen to page load
// events
socialLoginWindow
  .addEventListener(
    'loadstart',
    function(
      event) {
      var url = event.url;
      if (url == "http://www.magentomobileshop.com/demo/index.php/payu/index/success/") {
        socialLoginWindow
          .close();
      }

    });

And here is the reference link for it :-

https://forum.ionicframework.com/t/opening-external-link-and-closing-it-at-an-event/6660/9

Here "Loadstart" will track your every change of url in window.So, the current URL can be get from event.url

Cheers !!! Happy coding.

Community
  • 1
  • 1
sid
  • 1,116
  • 1
  • 10
  • 27
1

Use $window.close() in $window service. You can broadcast the result to another controller like this AngularJS – Communicating Between Controllers

can you check if this will answer your question How to close browser window in AngularJS

You can use the $window.location.href to check for the particular URL to be true

Community
  • 1
  • 1
Makjb lh
  • 432
  • 5
  • 16
  • Hey Makb , how can i check the url in webview, so that i can close my webview on that perticular Url. – user2028 Dec 19 '15 at 11:04