To call the user function when the object is displayed (popup, notification, ...), add the ML-OBJECT
attribute to the ML-OBJECT
element with a javascript code parameter.
You can use this call to trigger gamification, for example, to spin a wheel before the user clicks the "Try my luck" button.
Running the function
This is an example of running the update_window_content
user function, which you can insert in Settings > JavaScript:
<ml-object onload="update_window_content()"></ml-object>
This logic only applies to the ML-OBJECT
element, placing the onload attribute on any other non-standard element will be ignored.
Execute a function passing an object (window) identifier
If you use the keyword this
as a parameter, then a variable with the object of the current window will be passed. In this case, you can access the contents of the window via the following properties:
<ml-object onload="update_window_content( this )"></ml-object>
Example of a function with the win
argument
function update_window_content( win ){ /* routine */ }
Overview of the properties of the win
object:
win.id
- campaign idwin.el
- top element of the windowwin.doc
- parent element of the window, e.g. if it is placed in an iframewin.form
- form data object