0

I have two applications webApp1 and webApp2. In webApp1 , HTML page contains an tag on click of it an HTML page in webApp2 will be opened in new browser window, page contains one text box and save button. If user enters something in text box and click on save button, need to send a notification from webApp2 to webApp1 so that webApp1 can close the newly opened window and perform some operation after closing window.

How can I achieve this using Java script?

Nagendra
  • 191
  • 1
  • 3
  • 20

2 Answers2

0

Why not just call window.close() as part of the save button click function in webapp2?

cberenik
  • 121
  • 4
  • I agree with you. I forgot to mention that webApp1 should perform some operations once window is closed. If I just close the window, its not possible – Nagendra Sep 10 '15 at 17:10
0

What you are looking for is window.opener.

In Webapp1, window 1, you would have a function in javascript that would need to be done after closing.

function AfterClose() {
    // code to execute in Webapp1, triggered in Webapp2
}

In Webapp2, within your save function, do the following.

function Save() {
    // ...
    // code to save your information
    // ...
    window.opener.AfterClose();
    self.close();
}
Olivier De Meulder
  • 2,493
  • 3
  • 25
  • 30
  • Thanks for the solution. It works if both web applications are using java script technology. What if both web applications are using some different languages? – Nagendra Sep 11 '15 at 04:31
  • What other languages are you thinking of? Any processing on the browser's side would be in JavaScript. On the server side, you could use different languages. But pertaining to your question, JavaScript it is. – Olivier De Meulder Sep 11 '15 at 04:42
  • Like asp.net, VB script etc will also use same window.open() method to open a new window? – Nagendra Sep 11 '15 at 05:17
  • @Nagendra. You are confusing server-side languages and client-side scripts. If you are running your web application on a Windows Server, which it sounds like you do, you basically have the choice between two languages C# and VB. Regardless of the language, you use the .NET framework to build your application. On top of that you can do client-side scripting. These are programs that run on the client side, on the browser. The language of choice for that is JavaScript. (VBScript is something entirely different). – Olivier De Meulder Sep 11 '15 at 13:16
  • I assumed that VB script is a client side scripting language and VBScript is just as capable of accessing the DOM just as much as JavaScript is. Hence my question. But you are saying VBScript is something different? – Nagendra Sep 12 '15 at 05:54
  • Olivier, this solved my problem. Thanks for the solution. I assumed that VB script is a client side scripting language and it is just as capable of accessing the DOM as much as JavaScript is. Hence my question. But you are saying VBScript is something different? – Nagendra Sep 12 '15 at 06:00
  • VBScript is a Microsoft only. So what you pointed out may work on Internet Explorer. It is mainly used for other purposes though. See also this post. http://stackoverflow.com/questions/930716/alternatives-to-javascript – Olivier De Meulder Sep 12 '15 at 11:53
  • Ok Thanks. It was helpful – Nagendra Sep 14 '15 at 05:00