1

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

0

2 Answers 2

3

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.

2
  • what would be an example of re-adding or re-overwriting the type attribute with theme_html_tag() ?
    – Jurudocs
    Commented Apr 7, 2013 at 17:39
  • Not sure if I have a working example. Typically, I would start with the default implementation and adjust from there.
    – mpdonadio
    Commented Apr 7, 2013 at 20:31
5

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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