Q:

How to scroll automatically, if a page is clicked from a link

I want to make a page scroll-down with jQuery, but only if there's a click on a link to this page from another page. Both pages are in the same directory.
This is the code for the page to be scrolled:
var trigger;
$(document).ready(function(){
if (trigger == 'on') {
$('html, body').not('#jens').animate({
        scrollTop: ($('#geschaeftsstelle').offset().top)
    }, 500, 'swing' );
    } else {
        return false};
    });

But now, I don't know how to change 'trigger', if a clickevent on the linked page happens:
$('#kontakt').click(function(){
trigger = 'on';
};

I would appreciate any help. Thanks!

A:

$(document).ready(function(){
  if (window.location.hash) {
    $('html, body').not('#jens').animate({
        scrollTop: ($(window.location.hash).offset().top)
    }, 500, 'swing' );
    } else {
        return false
    };
 });

don't forget to use simple links like href="path-to-your-page.html#geschaeftsstelle" and no smth.click()

