Solved

Open fancybox automatically on page load

Posted on 2013-01-18
2
1,053 Views
Last Modified: 2013-01-21
I have code below to open Fancybox For Wordpress on page load and it's loading but the div cannot display content - just says "The requested content cannot be loaded.
Please try again later." My code (which I'm putting all in the page template) is:
<div id="newsregwrapper">
<div id="newsreg">
...content...
</div>
</div>
<script type="text/javascript">
       var $j = jQuery.noConflict();
$j(document).ready(function() {
$j("#newsreg").fancybox().trigger("click");
}); </script>

I know the quirk of FB for WP is you have to surround the targeted div in a wrapper (in this case newsregwrapper) but not sure you need it for this method (only from a link?).

So do I need the wrapper and what is the correct code please...thanks.
0
Comment
Question by:alexmaestro100
2 Comments
 
LVL 9

Accepted Solution

by:
WebDevEM earned 500 total points
ID: 38794179
Hi... I'm don't use WordPress, but I have an example of opening FancyBox on page load at http://jsfiddle.net/webdevem/5EV8r/.  What it does is I have a hidden link which is set up to call the FB, then simulate a click at page load time.  I think to merge this with your code would be something along these lines:
<a class="fancyTrigger" href="#newsreg">
<div id="newsregwrapper">
<div id="newsreg">
...content...
</div>
</div>
<script type="text/javascript">
       var $j = jQuery.noConflict();
$j(document).ready(function() {
    j(".fancyTrigger").fancybox();
    j(".fancyTrigger").trigger('click');
}); </script>

Open in new window

I hope this at least gets you on the right track, since I don't know the WordPress part of it.
0
 

Author Closing Comment

by:alexmaestro100
ID: 38800433
Perfect thanks!
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question