Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have a form that works fine outside of drupal where it called a script ..../default.js However this does not work inside drupal 6 when i copy the code from ym html/php file.

I have seen this line

 drupal_add_js('globals/default.js'); 

Is this all I need to add to get the JS read? I have the php filter in Drupal 6 set to allow pretty much all tags for the administrator.

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

Sounds to me like you're trying to call the drupal_add_js() function from within a node edit form (or maybe the body of a form). Instead of that, just change the body's input filter to HTML (or whatever filter you have that allows <script> tags) and call the external JavaScript there as you would in any HTML page. You don't need to use PHP for that.

I would add that that probably isn't best practice. Using drupal_add_js() is, but you should use drupal_add_js() in page templates (e.g., node.tpl.php) or in preprocessor functions (e.g., hook_preprocess_node()).

As an aside: be very careful of the PHP input filter, it has major security implications.

share|improve this answer
    
Hi, Thats what I thought I was having troubles getting it to work, but I will give it another go (using the php filter, but it is only allowed for the administrator, then I will look at cross site scripting / injection prevention). Thanks @cdmo –  Tom Jul 15 '13 at 8:10
add comment

Look at this examples. For a specific node take a look at this and this.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.