Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

close window in angularjs on specific url angularjs

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

like image 866
user2028 Avatar asked Nov 24 '25 14:11

user2028


1 Answers

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.

like image 98
sid Avatar answered Nov 27 '25 02:11

sid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!