Add Javascript

Category: 

  • Tip / Idea

You can add Javascript to your Drupal Cloud site by putting it into a Block:

1. Go to Structure (top menu) > Blocks > Add block
2. For Block title, enter "<none>"
3. For Block description, enter a description of your choice, e.g. "Javascript: open external links in new window"
4. Switch to "Full HTML" in the Text format drop-down.
5. Click on "Switch to plain text editor"
6. Place your Javascript between <script></script> tags.
7. Fill in the Show block on specific pages section as needed and save the Block.
8. Activate the block by placing it in a Region, e.g. the Footer.

Drupal supports jQuery natively, so you can attach your jQuery function to behaviors:

(function($) {

Drupal.behaviors.functionName = {
attach: function() {
// function actions here
}
};

})(jQuery);

8/14/13

Oops, I meant to add this to the Share Tips & Ideas section, sorry!

8/14/13

Fixed!

8/15/13