?
Solved

Open fancybox automatically on page load

Posted on 2013-01-18
2
Medium Priority
?
1,093 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 2000 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
While Plesk offers many potential benefits to website administrators, including compatibility with Windows Server and other leading technologies, the company has also been working to differentiate it from other control panels for content management…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 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