开发者

OpenjQuery Fancybox Lightbox automatically in Rails

开发者 https://www.devze.com 2023-03-05 08:14 出处:网络
I am using Fancybox to open up content in an iframe on my page, and开发者_C百科 it is working great.

I am using Fancybox to open up content in an iframe on my page, and开发者_C百科 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!!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消