Drupal tabs activated trough URL anchors

This is the code for calling a js file from the module

<?php
$path
= drupal_get_path('module', 'name_of _the_module');   
drupal_add_js($path .'/name_js_file.js');
?>

this is the js code for the functions
<?php
if (Drupal.jsEnabled) {
  $(
document).ready(function() {
    var
myFile = document.location.toString();
    if (
myFile.match('#')) { // the URL contains an anchor
        // click the navigation item corresponding to the anchor
       
var myAnchor = '#' + myFile.split('#')[1];
        $(
'ul.anchors li a[href="' + myAnchor + '"]').click();
    }
  });
}
?>

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><h2><h3><div><del><img><hr>
  • Lines and paragraphs break automatically.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 14 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.