Fancybox popup always scrolls on top | How to resolve it? (solved)

Hey forks,
Recently I was using fancyBox library for displaying photos in my website. Using it was a easy deal but I got stuck to a problem. But I got stuck with one issue, whenever user clicks on a image the page always scrolls to Top.

I just prevented default event of window by embedding a writing simple javascript code.

function preventDefault(e) {

  e = e || window.event;

  if (e.preventDefault)

      e.preventDefault();

  e.returnValue = false; 

}

I called this function just before fancybox() function so that page doesn't automatically  scroll to top.

Thanks for reading.


Comments