Solved

Open fancybox automatically on page load

Posted on 2013-01-18
2
1,039 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now