OpenjQuery Fancybox Lightbox automatically in Rails - javascript

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:
If the user goes directly to the link, redirect to the homepage and open in an iframe
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.

Related

how to click a link inside iframe

I want to click on a link inside iframe onload with the help of JavaScript, I have a site loading inside an iframe, now I want to click a link of a particular div (ID) on page load. The link is inside the iframe.
Actually I'm trying to change the language of the website which is loading in the iframe, the site has gtranslate plugin installed and has different language flag at the footer of the site.
Basically is it possible to force a page to be translated when the page loads?
The Same Origin Policy prevents you from scripting an Iframe from a different domain.
Possible answer here

How to load webpage in an iframe on click of a link of another iframe

I have two iframes (say 1 & 2) in a webpage. In the iframe1, I have a hyperlink on click of which, I want to load another webpage in the iframe2.
Can you please tell me whether loading a page from one iframe to another is possible and if so, please help in doing it. Thanks.
Note: all the web pages that I am considering here are in same domain.
use the name attribute on your iframes
then use target on your links
<iframe name='mydetails' src='someSrc.html'></iframe>
in your other iframe
<a href='details.html target='mydetails'>My details</a>

Open fancybox with url of page in address bar

I have stucked somewhere please have a look and get back to me if you have some idea on that:
I want to open a page in fancybox and url of page which is opened in fancybox should display in address bar. I dont want to display url with http://abc.com#divid it should be a proper url without #divid.
It should be something like that :
http://exanple.com/title1
here is my html code:
<a id="example1" href="general.php">Recent Trip to New York</a>
jQuery code:
$("a#example1").fancybox();
Is there any way I can implement the things like I have mentioned..
URL in the browser can be manipulated with HTML5 history, but in this case it would not be advised as the user is simply viewing another page via an iframe, and they remain on the parent page.
Mozilla Developers: Manipulating The Browser History

How to check if a webpage is loaded or not in the browser window,when redirecting from a different website?

My requirement is that I have a few hyperlinks on a webpage and when the user clicks on these hyperlinks I should redirect the user to an asp.net web page(Default.aspx) in a different website.
For the 1st time when the user clicks on one of the hyperlinks it will launch a new browser window with the Default.aspx loaded and then if the user clicks on some other hyperlink I want to redirect the user to the existing browser window(in which deafult.aspx is already loaded)with the content related to this particular hyperlink loaded,instead of launching a new browser window/tab.
But I am not sure of how to achieve this.I wonder if I can add some js to the asp.net Default.aspx page to achieve this.
Please could someone put me in the right direction?
Thanks
It sounds like the target property of the <a> tag will serve your purposes. Try:
Link 1
Link 2
Any clicks on the link subsequent to the first one should not result in additional windows.

How to use onclick on a iframe tag

How to use onclick in iframe tag to call a javascript.
I basically want redirect to other page when a user clicks on a iframe.I have added the facebook like button my site which is a iframe code. So once he has clicked on the like button i want him to get redirected to a thank you page
EDIT:
i don't want to redirect the iframe but i want to redirect the main page on any interactivity with iframe. On solution is on focus or or on click on iframe i should be able to redirect. Can i at least do it.
You can't do that. Facebook's XFBML elements (like the 'Like' button) are on a different domain than your own (and only function that way); using Javascript to modify that frame isn't possible due to security restrictions.

Categories

Resources