Hi. I'm using the drupal_add_js API function in my nodes to add specific Javascript to the page where that node is being displayed but there seems to be a little problem I'm not able to figure out.

When do this:

drupal_add_js( "var i = 0;", "inline", "header" );

I see this in my HTML page:

<script type="text/javascript">
<!--//--><![CDATA[//><!--
var i = 0;
//--><!]]>

However, when I place this in my header:

drupal_add_js( "var i = 0;", "inline", "header" );
drupal_add_js( "var j = 1;", "inline", "header" );

I see this in my page:

<script type="text/javascript">
<!--//--><![CDATA[//><!--
var i = 0;
//--><!]]>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var j = 1;
//--><!]]>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var i = 0;
//--><!]]>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var j = 1;
//--><!]]>

Both drupal_add_js function calls are printed twice. If I would add a third drupal_add_js it will triple.

Does anyone knows whats going on?

Thanks,
Luke

Comments

pan69’s picture

No ideas? Anyone?

bigkevracer’s picture

I'm having a similar problem at the moment, not real sure what the cause is.

Renee S’s picture

Me also.

stefan81’s picture

I have the same problem

broncomania’s picture

I got the same problem will this not fixed ?