• Hi,

    I’m trying to show some content in Fancybox using javascript only, as suggested here at #6. Start FancyBox on page load:
    http://fancybox.net/blog

    When I try this, I get a console error:

    TypeError: loading is undefined loading.hide();

    What might be causing this problem?

    My code looks basically like this:

    jQuery(document).ready(function ( $ ) {
    	$.fancybox(
    		'<h2>Hi!</h2><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis mi eu elit tempor facilisis id et neque</p>',
    		{
    			'autoDimensions'	: false,
    			'width'         	: 350,
    			'height'        	: 'auto',
    			'transitionIn'		: 'none',
    			'transitionOut'		: 'none'
    		}
    	);
    });

    https://wordpress.org/plugins/easy-fancybox/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Best use the Inline Content method in combination with a id="fancybox-auto". Follow the instructions on https://wordpress.org/plugins/easy-fancybox/faq/ under “Can I make an image or hidden content to pop up in FancyBox on page load?”

    Thread Starter hommealone

    (@hommealone)

    Thanks! That would be a different way to do it, yes. But I asked if there is a way to do it using only javascript.

    For example, if you don’t have access to add any hidden content to the page; perhaps it is a page created on the fly or by another author after the developer is no longer available. In my example, the content comes from the javascript file, not from anything on the page.

    Any idea why my code would be throwing that console error?

    Thanks again; any other suggestions would be appreciated.

    It’s probably because you inserted this snippet above the footer, which means it is run before fancybox has initialised. Try placing the script in the footer.php below the <?php wp_footer(); ?> line.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem launching Fancybox via javascript’ is closed to new replies.