How to execute js function in body onload

Hi, fellows

I have a js function which I want to be execute in

Is it possible to do that?

Thanks in advance.

0 votes

1 answers




Easiest way to achieve that is to use jQuery:

    jQuery(document).ready(function() {
      // javascript to execute on load
1 votes

And to include that easily I think the easiest way it to add this javascript fragment in a dedicate javascript file for instance name it myfunc.js

  • You create a regular Nuxeo project (not webEngine) with Nuxeo IDE.
  • Copy your myfunc.js file into src/main/resources/web/scripts/myfunc.js in your project.
  • Add this following contribution in src/main/resources/OSGI-INF/myproject-widget-contrib.xml

Here is the contribution:

 &lt;component name=&quot;fr.mycompany.myproject.widget.contrib&quot;&gt;
     &lt;!-- to be sure to be deployed AFTER the default configuration to override it--&gt;

    &lt;!-- first you declare your javascript resources --&gt;
    &lt;extension target=&quot;; point=&quot;resources&quot;&gt;
      &lt;resource name=&quot;myfunc.js&quot;&gt;

    &lt;!-- and you override a xhtml fragment present everywhere in default Nuxeo JSF pages
            to append your javascript fragment --&gt;
    &lt;extension target=&quot;; point=&quot;views&quot;&gt;
      &lt;view name=&quot;nuxeo5 includes&quot; template-engine=&quot;jsf-facelets&quot;&gt;