I am using this module Single Page Site to get a single page and it works well. However I want to get the navbar fixed when scrolling up the page but I cannot figure out how and where to put this jquery code in my site.

$(document).ready(function () {

  var navbar = $('.navbar');
  var origOffsetY = navbar.offset().top;

  function scroll() {
     if ($(window).scrollTop() >= origOffsetY) {
     else {


  document.onscroll = scroll;

Actually what I am trying to achieve is something similar to this website http://www.orisnv.be which itself using the modules Single Page Site.

I appreciate any help or hint.


1 Answer 1


It turns out the answer is simple. I just declare the javascript inside .info file. And by using Drupal.behaiors I implement the jquery that target the navbar to fix upon scrolling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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