user324861
user324861

Reputation: 1

How to construct a URL to open a iframe window with jQuery fancybox plugin (lightbox)

In my web site there is home page, and all other pages open using fancybox window - with iframe.

I want to be able to construct a URL like www.example.org/About.html which will send the user to my website and will open the iframed page {About.html} within the fancybox window.

Thanks for help.

Upvotes: 0

Views: 4552

Answers (2)

joe
joe

Reputation: 11

<?php    
$content_id_param = $_GET['id'];
if( ! in_array($content_id_param, $content_ids) ) return;
$link_id = str_replace("/", "-", $content_id_param);
?>
<script type="text/javascript">
    $(document).ready( function() {
        var link_id = "<?php print($link_id); ?>"; // PHP to javascript
        $("." + link_id + "-fancybox-link").trigger('click'); // using class, cause id is used for keyboard handling...
    });
</script>

Upvotes: 1

Rob King
Rob King

Reputation: 94

You should be able to do it with something like this:

<a id="about_link" href="about.html" class="iframe">About</a>

Then:

<script type="text/javascript">
$(document).ready(function(){
    $("a#about_link").fancybox();
});
</script>

The "class" attribute will tell Fancybox to load the accompanying URL into an iframe.

Upvotes: 0

Related Questions