goddamnyouryan
goddamnyouryan

Reputation: 6896

OpenjQuery Fancybox Lightbox automatically in Rails

I am using Fancybox to open up content in an iframe on my page, and it is working great.

This content has a share bar in it however, and when you click on the link posted on social media, it takes you directly to the content without opening it in an iframe, so the layout is all screwy.

I want to be able to either do:

  1. If the user goes directly to the link, redirect to the homepage and open in an iframe
  2. Give the user an alternate layout if the link is clicked from a link that doesn't have class="iframe"

I am using Rails 3 to build my site, and I found this post about opening the content in an iframe automatically, the problem is if a user clicks on the link on my site (with class="iframe") it opens an iframe within the iframe!

Is there a good workaround for this?

Does this make sense?

Thanks!!

Upvotes: 0

Views: 475

Answers (1)

wewals
wewals

Reputation: 1447

In javascript you can check to see if the page is already in an iframe

var isInIFrame = (window.location != window.parent.location) ? true : false;

You can do this check onclick to decide whether or not to load the content in an iframe.

Is this helpful? I'm not sure that I completely understand the question.

Upvotes: 1

Related Questions