Call JS function on page load

asked 2010-02-02 00:25:55 +0800

din gravatar image din
251 1 5

I want to execute a javascript function on load of page, how can I do that?
Please Help!!!


delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2010-02-02 10:07:48 +0800

kesavkolla gravatar image kesavkolla
180 3

updated 2010-02-02 10:11:29 +0800

If you want to execute script on page load

<?script type="text/javascript" content="
alert('this is my page load script');

The above will add code between

. This will get executed as soon as the pages is served to browser. Remember the DOM is not ready yet so you can't access any page elements etc..

If you want to execute some script after the DOM is ready you can enhance the above like the following:

<?script type="text/javascript" content="
jq(function($) {

This will executes as soon as the DOM ready. But if you are working with zk none of page elements are ready at this tim also. ZK has it's own life cycle.

You will have to use:

 zk.aftermount(function() { alert('hello');});


link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2010-02-02 00:25:55 +0800

Seen: 880 times

Last updated: Feb 02 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More