This particular topic has some answers on SO, but none of them solves my problem. I have no idea where to look here, although I suspect it’s something very simple.
- When I try to open a url in a Fancybox manually (i.e. by ‘physically’ clicking a link) it works.
- If I however try to open it on page load automatically (i.e. by faking clicking a link), it doesn’t work at all and gives me the error I mention in my title.
The HTML is simple:
<a href="http://www.mydomain.nl/url/to/whatever" class="fancybox hidden_link">test</a>
The Javascript I’m using to automatically click it, is pretty straightforward too:
$(document).ready(function() {
$(".hidden_link").fancybox().trigger("click");
});
The event goes off (a Fancybox opens), but it shows nothing more than the ‘content cannot be loaded’ message.
I see my own page in the Fancybox when I click the link manually.
What am I missing here?
Having this link :
… this script :
… should do the job for both, manually and programmatically.
See JSFIDDLE
Notice that I used
type: "iframe"since the content is an external page. The same origin policy should be considered in any case.