How to automatically trigger a javascript function on load

m4trix.dev
36 Posts
m4trix.dev posted this 01 December 2021
Ask a Question

Hello

I have a script with a function declared. I would like that function to be run at the time the page load and I understood I can simply add the following attribute to the body tag.

<body onload="myFunction()">

How can I achieve this in Nicepage without manually modifying the exported html file?

thanks

Vote to pay developers attention to this features or issue.
3 Replies
Order By: Standard | Newest
Support Team
Support Team posted this 02 December 2021

Hi, Matteo,

Thanks for being our customer!

Unfortunately, you can add this attribute only after the export. Only one BODY tag can be on a page. The second tag cannot be added, and the new attribute also can't be added to this tag.

Let us know if you need our further help.
...................................................
Sincerely,
Paul C.
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Matt Dub
29 Posts
Matt Dub posted this 13 February 2025

Hello

I have a script with a function declared. I would like that function to be run at the time the page load and I understood I can simply add the following attribute to the body tag.

How can I achieve this in Nicepage without manually modifying the exported html file?

thanks

So this can be closed...and referenced by others...

Use something like this in one of the html controls or in your own existing script:

window.onload = function onload() {

myFunction();

}

Support Team
Support Team posted this 14 February 2025

Hi, Matt Dub,

Thank you for the provided information! We hope it will be helpful for our users.
...................................................
Sincerely,
Paul C.
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

You must log in or register to leave comments