Widget Instance

Hi, does anyone know how to get the widget instance value?
When the user add a widget I want to know the instance id that was created… I need this information inside the widget… not in the main app…

Thank you for your time…

Please check this

The Web widget applications support the following events: onload , onclick , and visibilityChange :

  • onload This event is generated when the Web widget content is loaded onto the widget board. Use it to implement Web widget initialization procedures. For example, initialize Web widget configurations by reading shared data from the parent Web application.
<element onload="load">
/* JavaScript */

/* Define the event */

/* Set the event listener */
object.addEventListener('load', load);

/* Define the event handler in the main.js file */
function load() {
    /* Load water data from shared file */

    /* Change the current amount of water */
    document.getElementById('currentWaterNum').textContent = currentWaterNum;

    /* Change the color of the water cups */
    for (var i = 1; i <= currentWaterNum; ++i) {
        document.getElementById('watercup' + i)).style.backgroundColor = 'blue';


Also please check Widget lifecycle,

Thank you,
Samsung Developer Program

1 Like