<?php // This add inline JS to the head of the document
drupal_add_js('alert("Hello!")', 'inline');
drupal_add_js("var automatic_logout = true;", 'inline');
/* Output in the Webpage:
<script type="text/javascript">
var automatic_logout = true;
</script>
*/
// This will add variables in the Drupal.settings object
drupal_add_js(array('my_module' => array('my_setting' => 'this_value')), 'setting');
drupal_add_js(array('contactus' =>
array('argCustom' => 'custom',
'cleanUrl' => 'true',)),
'setting');
/* Output:
<script type="text/javascript">
jQuery.extend(Drupal.settings,
{ "contactus": {
"argCustom": "custom
",
"cleanUrl": "true" }
});
</script>
*/
?>
No comments:
Post a Comment