How can I activate a horizontal tab? Drupal 7 has the field group module which contains a horizontal_tab.js file. 

Inside this file i found this written

// If the current URL has a fragment and one of the tabs contains an
// element that matches the URL fragment, activate that tab.
if (window.location.hash &amp;&amp; $(window.location.hash, this).length) {
   tab_focus = $(window.location.hash, this).closest('.horizontal-tabs-pane');
}


Can someone explain how this would work and what exact url i should call so that a particular tab is activated.
window.location.hash returns the part of the URL after the #, including the #.
Passing to $() a string like, for example, "#tab1" selects any element that uses "tab1" as ID. (Differently, ".tab" selects any elements that uses "tab" as CSS class.)

$(window.location.hash, this) select all the elements that has window.location.hash as CSS selector, using this as context; this is the element on which an handler is triggered.
$().closest() returns then the first ancestor element that matches the selector passed ad argument.