Si je veux ajouter JavaScript dans la balise head, j'utilise drupal_add_js($js, 'inline')
. Cela ajoutera un <script type="text/javascript">
.
Comment ajouter le <noscript>
tag? Je veux également ajouter ce qui suit <head>
.
<noscript>
<meta http-equiv="refresh" content="5;url=<?php echo $file ?>" />
</noscript>
BTW, j'utilise un module simple pour cela.
function custom_download_menu() {
$items['download-code'] = array(
'title callback' => 'custom_download_page_title',
'page callback' => 'custom_download_view',
'access arguments' => array('access content'),
'access callback' => TRUE,
);
return $items;
}
function custom_download_view() {
$js = "var time_left = 5;
var cinterval;
function time_dec(){
if(time_left > 0) time_left--;
document.getElementById('countdown').innerHTML = 'Your download will start in ' + time_left + ' seconds...';
if(time_left < 1){
clearInterval(cinterval);
window.location = '<?php echo $file ?>';
}
}
cinterval = setInterval('time_dec()', 1000);";
drupal_add_js($js, 'inline');
}