Hello,

Im using Drupal 6.19.In my Drupal page i have the input format set to PHP code.I have included a JS file using the following line of PHP:

print "<script src=\"my_site_includes/js/script.js\"> </script>";

The page is set as the front page and attached to a primary menu item.But the js is not executed when i access the site. However if i edit the page and click save, the js executes. This is really strange, as i have to edit the page and hit save for the js to execute. What could be going wrong here ?.

Please Help
Thank You.

Comments

CMS’s picture

try including the path to your js in your theme's .info file
eg: scripts[] = /js/scripts.js

Vj’s picture

Thats how it worked for me, hope it will help you

1. add your ***.js file to theme .info file

scripts[] = ***.js

2. go to template.php of your theme and add

drupal_add_js(drupal_get_path('themes', '/***.js'));

3. write the valid code for js in ***.js file.

for trial to check js working or not replace your code with this and check the alert box coming or not

// $Id$
// gives an alert box.
if (Drupal.jsEnabled) {
  alert("I am an alert box!");
}

4. enable javascripts in admin/settings/performance.

5. clear cache every time you change ***.js file