Drupal Questions & Answers

Ask and answer Drupal related questions! No question too simple or complex!
runeveryday's picture
Asked by on Sun 12th Sep 2010
drupal_add_js()

i put this code into template.php.but it didn’t work.when i access the page (example.com/myform)

function mytheme_preprocess_page(&$vars, $hook) { 

if (arg(0)=='myform') { 

drupal_add_js( 

drupal_get_path('theme', 'mytheme') .'/myform.js',  

  'theme'

  ); 

  } 


}

i have cleared the cache, it still can’t work. if i put this line (scripts [] = myform.js)into the info file,it works, why?

Commenting on this Drupal Question is closed.