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(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users