Adding Functionality with JavaScript
Return to Drupal Cloud Landing Page
You can add Javascript to your Drupal Cloud site by putting it into a Block:
- From the Admin menu click Structure, then Blocks, then Add block.
- For the Block title, enter <none>
- For the Block description, enter a description of your choice, e.g. "Javascript: open external links in new window"
- Switch to Full HTML in the Text format drop-down.
- Click on Switch to plain text editor
- Place your Javascript between <script></script> tags.
- Fill in the Show block on specific pages section as needed and save the block.
- 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);