8

If I want to add JavaScript in the head tag, I use drupal_add_js($js, 'inline'). This will add a <script type="text/javascript">.

How do I add the <noscript> tag? I want to add the following in <head> also.

<noscript>
  <meta http-equiv="refresh" content="5;url=<?php echo $file ?>" />
</noscript>

BTW, I'm using a simple module for this.

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');
}
10

You can add elements to the <head> section of a web page using drupal_add_html_head().

$target = url('enable-javascript', array('absolute' => TRUE));
$meta = array(
  '#theme' => 'html_tag',
  '#tag' => 'meta',
  '#attributes' => array(
    'http-equiv' => 'refresh',
    'content' => "2; url=$target"
  )
);
$noscript = array(
  '#theme' => 'html_tag',
  '#tag' => 'noscript',
  '#value' => drupal_render($meta)
);
drupal_add_html_head($noscript, 'noscript');

API Documentation

0

You can use this Noscript Tag contributed module.

URL: https://www.drupal.org/project/noscript_tag

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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