Skip to main content
Tweeted twitter.com/StackDrupal/status/807371054117253121
Improved formatting and corrected spelling.
Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

Is it possible to declairdeclare option inside drupal_add_js?

Improved formatting and corrected spelling.
Source Link

Is it posiblepossible to declair option inside drupal_add_js?

I'm stuck on including an external javascriptJavaScript file on a custom page. The apiAPI service requires the htmlHTML to be formatted as below

<script type="text/javascript" src="//platform.example.com/api.js">
api_key:   [key]
</script>

No idea if this can be done the drupalDrupal way. I tried:

// load SDK
drupal_add_js('//platform.example.com/api.js', 'external');
drupal_add_js('api_key:   [key]', 'inline');

But without successuccess. The api_keyAPI_key declaration need to be done inside the first tag that links to the external jsJS. I know you can add extra parameters like documented on https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_js/7.x but this case is not described.

I'm using D7 btw.

Thanks in advance!

Is it posible to declair option inside drupal_add_js

I'm stuck on including an external javascript file on a custom page. The api service requires the html to be formatted as below

<script type="text/javascript" src="//platform.example.com/api.js">
api_key:   [key]
</script>

No idea if this can be done the drupal way. I tried

// load SDK
drupal_add_js('//platform.example.com/api.js', 'external');
drupal_add_js('api_key:   [key]', 'inline');

But without succes. The api_key declaration need to be done inside the first tag that links to the external js. I know you can add extra parameters like documented on https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_js/7.x but this case is not described.

I'm using D7 btw.

Thanks in advance!

Is it possible to declair option inside drupal_add_js?

I'm stuck on including an external JavaScript file on a custom page. The API service requires the HTML to be formatted as below

<script type="text/javascript" src="//platform.example.com/api.js">
api_key:   [key]
</script>

No idea if this can be done the Drupal way. I tried:

// load SDK
drupal_add_js('//platform.example.com/api.js', 'external');
drupal_add_js('api_key:   [key]', 'inline');

But without success. The API_key declaration need to be done inside the first tag that links to the external JS. I know you can add extra parameters like documented on https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_js/7.x but this case is not described.

Source Link

Is it posible to declair option inside drupal_add_js

I'm stuck on including an external javascript file on a custom page. The api service requires the html to be formatted as below

<script type="text/javascript" src="//platform.example.com/api.js">
api_key:   [key]
</script>

No idea if this can be done the drupal way. I tried

// load SDK
drupal_add_js('//platform.example.com/api.js', 'external');
drupal_add_js('api_key:   [key]', 'inline');

But without succes. The api_key declaration need to be done inside the first tag that links to the external js. I know you can add extra parameters like documented on https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_js/7.x but this case is not described.

I'm using D7 btw.

Thanks in advance!