Onload in the widget

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 01:57 AM
Hi Everyone,
Can anyone tel me how i can use onload to call another function.
example in HTML : ( <body onload="someFunction()"> ...</body>)
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 02:03 AM
Hi Adil,
Use ng-init="functionName()" this function will execute when the widget or the variable you specified it withing loads.
Let me know if it works.
Regards,
Mayur

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 02:34 AM
Hi Mayur,
thanks for your answer.
I have already use it but it does not work 😕
this is what i did:
html
<div ng-init="test()">
</div>
client script:
function test(){
alert('hhh');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 06:37 AM
Hi Jebli,
Please use the below code.
HTML:
<div ng-init="c.onload()">
</div>
Client script:
function() {
var c = this;
c.onload = function(){
alert("onload");
}
}
Let me know if you need any assistance.
Thanks
Naveen K

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 11:27 AM
I am having a related issue, however, mine is more specific to the widget not being populated with the script is run, rather it shows up at the bottom of the parent page.
https://community.servicenow.com/community?id=community_question&sys_id=f1ff1814db00e8549e691ea6689619aa