Search code examples
javascriptjqueryfancybox

Fancybox to the center of the screen


I show a pop-up with javascript Fancybox on page load. My problem is, that pop-up shows at the center of the web page and not at center of the screen. So pop-up is actually moved down and user do not see it, until he scroll down. But I also included centerOnScroll, so pop-up goes down, when you scroll down and you can not see it in any way. Could someone help me to place my pop-up to the center of the screen? Thanks a lot!

Here is my part of code:

$("#hidden-link").fancybox({
    centerOnScroll: true,
    overlayColor: "#000",
    overlayOpacity: 0.9,
    modal: true

}).trigger('click');

Solution

  • While technically this isn't an answer. My first suggestion would be to upgrade and use the latest version of fancybox instead.

    The method "centerOnScroll" is from Fancybox 1 - I would suggest using version 2 instead which fixes is a lot of problems that version 1 had. You might find that simply upgrading to the latest version fixes your problem.

    Version 2 is available here and has many new features: http://fancyapps.com/fancybox/

    See how you get on with version 2. If you are still having trouble show us more of your code.

    Good luck!