[xwiki-users] javascript onload on a single page

2008-03-20 Thread Joao Henrique Silva Santos
Hi.

I have a javascript with an 'onload' which I only want to be loaded on
a single certain page.
I have achieved this by putting an

script type=text/javascript
   [...]
   window.onload=someFunction();
   [...]
/script

on the beginning of the page, on wiki edit mode.
However, this doesn't seem very clean to me. Is there a better way to
do it? If so, how?

regards,
Joao
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] javascript onload on a single page

2008-03-20 Thread Joao Henrique Silva Santos
Thanks!

On 20/03/2008, Sergiu Dumitriu [EMAIL PROTECTED] wrote:
 Joao Henrique Silva Santos wrote:
   Hi.
  
   I have a javascript with an 'onload' which I only want to be loaded on
   a single certain page.
   I have achieved this by putting an
  
   script type=text/javascript
  [...]
  window.onload=someFunction();
  [...]
   /script
  
   on the beginning of the page, on wiki edit mode.
   However, this doesn't seem very clean to me. Is there a better way to
   do it? If so, how?
  


 You should use:

  Event.observe(window, load, someFunction);

  And concerning where to put the script, two options:

  - javascript.vm, surrounded by something like:
  #if($doc.fullName == My.Document)
  Event.observe(window, load, someFunction);
  #end
  This file is located on the filesystem, either in
  xwiki-dir/skins/albatross/ or in xwiki-dir/templates/, depending on
  what version are you using.

  - In the actual document, as you put it already, since it is just one
  document, while javascript.vm is used for all documents.


  --
  Sergiu Dumitriu
  http://purl.org/net/sergiu/
  ___
  users mailing list
  users@xwiki.org
  http://lists.xwiki.org/mailman/listinfo/users

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users