Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Open fancybox automatically on page load

Posted on 2013-01-18
2
Medium Priority
?
1,085 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
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!
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
Suggested Courses

636 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