Javascript, refresh container on window.onfocus

Hi all,

I'm trying to implement a function in javascript that runs when i set focus on window. For now i have on the preparation of my screen (in a RunJavascript action) this code;

"window.onfocus = function() {window.close()};"

It is working, every time a set the focus on that window it appears a confirmation message to close the window. But, what i'm trying to do is;
By the ID of one container, refresh his content. Is that possible ? Is this the right way to do it ?

Based on this post i'm trying to call an action when function window.onfocus take place was. I have attached an example, but i getting an error in document.getElementById". Can anyone check this, and help me on this?
HI António,

instead of having document.getElementById(Hiddenbutton.Id). click();

try document.getElementById("'" + Hiddenbutton.Id + "'").click();

Hello Ricardo. Thanks for your reply.

I have now, something like this.

window.onfocus = function xpto()
document.getElementById("'" + Hiddenbutton.Id + "'").click();

But it keeps with an error..

Mensagem: 'Hiddenbutton' não está definido
Linha: 3
Caráct: 1
Código: 0
URL: http://localhost/CallAction/admin/CallFunction.js?239


instead of using style property display "display: none;" , use Visible = False property instead (that is how you should make invisible the objects)

If the goal is to see a feedback message in screen then, you have to have a reference to webblock RichWidgets\Feedback_Message and have one in your page

You could use the RichWidgets\Listlateload webblock to trigger the screen action you need, instead of writing javascript.


Thanks for the tip, but the main goal of this example, is trying to understand, and learn how to call an action using javascript. By using event window.onfocus.
Hi Antonio,

in that case use document.getElementById('wtHiddenbutton').click();

You can see the generated code that the there is a prefix Wt in button.