This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

equivalent to "window.onload"
#1
Hi all,


I'm looking for this method :
how to detect that a page (whatever this page, not a particular page) has just been loaded, with an equivalent of "window.onload" in javascript?

Someone knows the solution (Erwin for example ;-))?

Have a good day !
Reply
#2
Can you explain what are you trying to achieve?
Reply
#3
Hi ,

here is my need:
with custom JS, change the value of a group [JS grp.write()] each time a page of the visualization is accessed by a user.
Note: that's why I was referring to the JS instruction "window.onload".

It is necessary for this:
1. I detect the Id of the activated page
2. I write in a value in a group

Hoping you have been more accurate ...
Reply
#4
Hi,

You can do that like this:
Code:
$(function(){
  $('body').on('showplan', function(e, id) {
     grp.write('1/1/1', id);
  });
});
BR,

Erwin
Reply
#5
Hi,

I want to write an object before I close visualization window.

I think the function is "window.onbeforeunload" but witch is the equivalent?

Is there any page to see all javascript function in Logic Machine?

Thanks!!
Reply
#6
The visualization runs in a browser not in LM. The supported functions is what the browser supports.

This can be used to switch an object off when the visualization page is exited:
Code:
window.onbeforeunload = function() {
  if ($('body').hasClass('usermode')) {
    grp.write('32/2/21', false);
  }
};
Reply
#7
(25.06.2021, 11:48)admin Wrote: The visualization runs in a browser not in LM. The supported functions is what the browser supports.

This can be used to switch an object off when the visualization page is exited:
Code:
window.onbeforeunload = function() {
  if ($('body').hasClass('usermode')) {
    grp.write('32/2/21', false);
  }
};


Thanks!! It worsk perfectly.

I have another question, I want to know when a visualization is opened and I put this code:

Code:
  grp.write('32/1/152', true);
 
  window.onbeforeunload = function() {
    if ($('body').hasClass('usermode')) {
      grp.write('32/1/152', false);
    }
  };

But doesn´t work.

What is wrong?

Thanks!
Reply
#8
You have to wait for the WebSocket connection to be established. Use this:
Code:
if (typeof localbus === 'object') {
  $(localbus).on('connect', function() {
    grp.write('32/1/152', true);
  });
}
Reply


Forum Jump: