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
2253 views
Hi,
Easiest way to achieve that is to use jQuery:
<script>
jQuery(document).ready(function() {
// javascript to execute on load
});
</script>
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:
<component name="fr.mycompany.myproject.widget.contrib">
<!-- to be sure to be deployed AFTER the default configuration to override it-->
<require>org.nuxeo.theme.nuxeo.default</require>
<!-- first you declare your javascript resources -->
<extension target="org.nuxeo.theme.services.ThemeService" point="resources">
<resource name="myfunc.js">
<path>scripts/myfunc.js</path>
</resource>
</extension>
<!-- and you override a xhtml fragment present everywhere in default Nuxeo JSF pages
to append your javascript fragment -->
<extension target="org.nuxeo.theme.services.ThemeService" point="views">
<view name="nuxeo5 includes" template-engine="jsf-facelets">
<resource>myfunc.js</resource>
</view>
</extension>
</component>
01/30/2012