Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

i'm adding javascript with

drupal_add_js()

but drupal cuts the script attribute "text/javascript" or just forgot it. It just adds the

<script></script>

tags. Can i add the script tags? Its w3c standard...;-P

share|improve this question

2 Answers

up vote 3 down vote accepted

The default drupal_get_js() includes the type attribute (look at the source). I suspect you have a module or theme that is implementing a theme_html_tag() that is stripping the type out.

I suggest looking through your theme and/or base theme for this theme function. You could also implement your own version in your theme, and put back in the type.

If you are using any of the modules that "cleanup" HTML output, then I would try disabling them. I have seen them do really weird things on pages.

share|improve this answer
what would be an example of re-adding or re-overwriting the type attribute with theme_html_tag() ? – Jurudocs Apr 7 at 17:39
Not sure if I have a working example. Typically, I would start with the default implementation and adjust from there. – MPD Apr 7 at 20:31

On the off-chance that you're using an HTML5 DOCTYPE, you don't need to worry:

The type attribute gives the language of the script or format of the data. If the attribute is present, its value must be a valid MIME type. The charset parameter must not be specified. The default, which is used if the attribute is absent, is "text/javascript".

Emphasis mine

Source: HTML 5.1 Nightly - 4.3 Scripting

share|improve this answer

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.