By Anonymous (not verified) on
Hi !
In Drupal 4.7, I don't understand how to add a javascript file in my page.tpl.php and how to write an onload attribute ?
I hope you can help me ;)
Thanks
Matt
Hi !
In Drupal 4.7, I don't understand how to add a javascript file in my page.tpl.php and how to write an onload attribute ?
I hope you can help me ;)
Thanks
Matt
Comments
there is a head section in
there is a head section in the page.tpl.php where you can but your javascript definitions and a body tag where the onload can be placed to
load your functions
put <script language="JavaScript" src="yourfolder/yourfile.js"></script> in the head section
---
Join the virtual march to stop global warming.
http://www.stopglobalwarming.org/marchers/?142067
Yes, it's the usual way but...
Thanks.
Yes, it's the usual way but in 4.7, the collapsible elements script doesn't work anymore if I use this solution. :-/
Hiya... addLoadEvent for Javascript
We also struggled with this one...here's a hand.
Drupal.js uses addLoadEvent which is a function that replaces window.onload();
In order to make the function work add this code to your page and make sure that drupal.js is also being loaded in every page that you require the event to be called. From my understanding (limited) drupal.js is called in the admin sections, that use collapsable elements. We manually added a reference to drupal.js in our page.tpl.php so that the addLoadEvent is called on every page, but there may be a better solution. As it stands now, drupal.js is called twice in the admin section. It works perfectly.
Love, Live, Laugh
Thanks ;)
Thanks a lot for your help... I'll try this solution... ;)
Can you explain it more specifically...
I am stumped still... (Not hard to do!)
I am trying to get the following javascript (popup Window) to work:
I had this code placed in a block - and it worked fine... I now want to move it to my page.tpl.php.
Thanks for any and all help!