window.open
Question
Application Type
Reactive

Using (window.open) to open the child screen, I want the following effect

1. The main screen and the child screen pass values to each other

2. On the main screen, if the child screen have been opened, click the button again and the message will be "child screen Open".

3. Click the Clear button of the child screen to clear the value of the main screen

If you have any good methods or ideas, please let me know. Thank you

mvp_badge
MVP

Hi,

Not sure what you try to achieve, for which there might be a low-code OutSystems solution.

But regarding establishing communication between browser tabs or windows, you might want to read the following article for ideas to try out:

https://blog.bitsrc.io/4-ways-to-communicate-across-browser-tabs-in-realtime-e4f5f6cbedca

Regards,

Daniel

Hii

You can do this with a small JS

var winPop = false;

function OpenWindow(url){

  if(winPop && !winPop.closed){  //checks to see if window is open

    // You can disable the Button

  }

  else{

    // Keep button Enable

  }

}


Replace URL with the Child window URL

mvp_badge
MVP

I don't see how this enables communication between both windows, also your JS is questionable.

You define a variable and assign it the value false.

Then you have this condition where you use winPop as a boolean variable and as an object with a closed property

 if(winPop && !winPop.closed) 

Hello Daniel 

Greetings!

Glad to see your response. I made one mistake sorry - 

<script>

var winPop = window.open("https://www.google.com");

function OpenWindow(){

  if(winPop && !winPop.closed){  //checks to see if window is open

    // You can disable the Button

    alert("1");

  }

  else{

    // Keep button Enable

    alert("2");

  }

}

</script>


Yes, but it will only work if the Child Screen is open from the Parent Window only. That should be open with JS Function. 


mvp_badge
MVP

Still don't see how this answers the question

Okay, so let me help you to understand please - 

<script>

var winPop = window.open("https://www.google.com");

When any user will click on button at parent screen we need to trigger this and it will open the Child Screen with capturing a value in Variable. 


function OpenWindow(){

  if(winPop && !winPop.closed){  //checks to see if window is open

    // You can disable the Button

    alert("1");

Now, we have one value that will check if the Child Window is open, here we can put code to alert "Child Screen is Open" if button clicked. The alert will need to be set. If @QQQ OOO has doubt on adding this, we can help.  

  }

  else{

    // Keep button Enable

    alert("2");

If you will close the Child Window opened from Parent Screen, it will come on this loop and allow to Open the Child Screen Again. Here again @QQQ OOO will put the Window Open and Set Var Value.  

  }

}

</script>

mvp_badge
MVP

How does your solution answer the following questions:

1. The main screen and the child screen pass values to each other?

So both windows are open and need to interchanges values

3. Click the Clear button of the child screen to clear the value of the main screen

How you handle while the child screen stays open an action is executed on the main screen?

Yes, it doesn't answer Point 1 and 3 but they are independent from the JS I have shared to achieve Point 2. They are the part where I am not experienced. 

@Daniël Kuhlmann @Manish Gupta

Thank you for your help. At present, we have chosen to change the plan and will use PopUp for development

In addition, for these requirements, it is possible to use the js+Client variable.This has been tried locally

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.