0

I am using fancyapps.com's FancyBox and I was wondering how to call a fancybox.ajax when the page loads.

Here is what I have:

$(document).ready(function(){
    $("#what").fancybox();
});

<a href="what.html" id="what" class="fancybox fancybox.ajax"></a>
Randyka Yudhistira
  • 3,612
  • 1
  • 26
  • 41
4WebDev
  • 85
  • 3
  • 9
  • It's been answered here: http://stackoverflow.com/questions/807271/how-to-launch-jquery-fancybox-on-page-load – K Z Apr 07 '12 at 20:14

1 Answers1

0

call the method on document ready

HTML

<a id="myFancybox" href="http://mydomain.com/mine.jpg" />

and script is

$(function(){

    $("#myFancybox").fancybox();

});

http://api.jquery.com/ready/

document.ready specify a function to execute when the DOM is fully loaded.

Shyju
  • 214,206
  • 104
  • 411
  • 497
  • Ok but what is the method to call file.txt via ajax? – 4WebDev Apr 07 '12 at 20:12
  • @4WebDev: Give your remote file name as the value of href proprty. Fancy box will bring the content of that file in the fancybox – Shyju Apr 07 '12 at 20:18
  • Yeah I just tried it and no luck... Here is what I have $(document).ready(function(){ $("#what").fancybox(); }); – 4WebDev Apr 07 '12 at 20:20
  • @4WebDev: Probably you have some other script errors in the page, check for the console tab of firebug to see what are those – Shyju Apr 07 '12 at 20:21