how to get page load event

how to get page load event

por Alpesh Mistry -
Número de respuestas: 9
hi
i trying to find how can we get the page load event in moodle.
what want is i create a one page that using moodle api like print_header,print_footer etc.
when this page load i want to call one javascript function named pageload()
so how can i do this.
i found that if i write in html page like this
<body onclick="pageload()">
then it will work but in moodle how can i do it?

Promedio de valuaciones (ratings): -
En respuesta a Alpesh Mistry

Re: how to get page load event

por Dale Davies -
Imagen de Particularly helpful Moodlers Imagen de Plugin developers
Can you not call pageload() in the footer?
En respuesta a Dale Davies

Re: how to get page load event

por Alpesh Mistry -

I want to call my own java script function in the page load of a php page, In simple html page we can do the same by just calling fuction in <body>, "onload" event, how can we do this in moodle system?
as i cannot see body tag anywhere in php page.

Thanks for the help.
En respuesta a Alpesh Mistry

Re: how to get page load event

por Tim Hunt -
Imagen de Core developers Imagen de Documentation writers Imagen de Particularly helpful Moodlers Imagen de Peer reviewers Imagen de Plugin developers
Use the YUI on DOM ready event.
En respuesta a Tim Hunt

Re: how to get page load event

por Alpesh Mistry -

thanks for reply

Tim

i tried to find it but i don't get it.
if you explain more about DOM ready event.
if possible then give me example of it.

En respuesta a Alpesh Mistry

Re: how to get page load event

por Paul Holden -
Imagen de Core developers Imagen de Moodle HQ Imagen de Moodle Workplace team Imagen de Particularly helpful Moodlers Imagen de Peer reviewers Imagen de Plugin developers Imagen de Testers
See this post and it's parent thread - your question is probably answered there approve
En respuesta a Paul Holden

Re: how to get page load event

por Alpesh Mistry -
hi
i tried but didn't get the solution if any body know then please tell me its urgent.
i want to call javascript function as page loaded on client pc
En respuesta a Alpesh Mistry

Re: how to get page load event

por Tim Hunt -
Imagen de Core developers Imagen de Documentation writers Imagen de Particularly helpful Moodlers Imagen de Peer reviewers Imagen de Plugin developers
In your PHP code somewhere do

require_js('yui_dom-event');
require_js('myscripts.js');

Then in myscripts.js, do something like

function init_my_feature() {
// Whatever.
}

YAHOO.util.Event.onDOMReady(init_my_feature);

Development:JavaScript_guidelines and
http://developer.yahoo.com/yui/event/ should help you understand this.
En respuesta a Alpesh Mistry

Re: how to get page load event

por Dale Davies -
Imagen de Particularly helpful Moodlers Imagen de Plugin developers
Alpesh, look for your theme's header.html or footer.html file. This can be found in the "theme" directory. You will find the body tag opened in the header file and closed in the footer file.