How to add javascript to Drupal Nodes  

Another problem with Drupal Nodes.

This time I was trying to configure a basic node with some javascript to show rotating links. I designed the entire page in macromedia (I usually do that and then copy the code back on drupal node) and checked everything and then pasted the code back on drupal node. But then this problem came up, how should i move the javascript code that I have defined in the head section of my html page into the drupal node. As such I cannot modify the head section of individual drupal nodes.

The solution:
This is how I added the javascript code to this drupal node.
I moved my entire javascript code into a .js file, i.e. the content between script tags. I then copied this .js file onto a definite location on my server. Now I could simply call this js file from the drupal node page without writing the entire script again and utilize it the way I want. Finally i had what I needed, a rotating image gallery using javascript on a drupal page :).

I have removed it as of now so can't put it on display but will show you another javascript example as soon as i get it ready.

PS: If this posts helps you in anyway please comment and support :)

AddThis Social Bookmark Button


Post a Comment