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
Related
I want to display my website in iframe of other domain(s). When displayed in iframe of that domain, I want to perform some actions like hiding/displaying content. Pages from my website are also iframed in same domain as well. So there is dynamic behavior. How do I find out where is my page iframed? There will be navigations from one page to another in iframe and whenever full page load happens, I want to know the context/parent where my page is iframed.
Using postMessage is not an option because it is async and I don't have control over other domains/apps. I found out iframe name can be accessed from following question -
access iframe name from inside iframe
Can I use it to find out the iframe context. (I can ask other domains/apps to set particular name to iframe so that they get correct rendering of the page)
I want jquery or javascript to access DOM in Iframe.
For example, I make a iframe to show amazon.
then I wanna get a banner image link on amazon.
Can I do this?
and I have one more problem.
if I click amazon banner that is made a by _blank target on "a" Tag in a iframe,
browser make a new tab. but I wanna see a new page in a iframe.
You cannot do that if the origin of the iframe is different from the parent document :
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
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>
I have a website with an iframe on one page that goes to an external URL (which I have no control over). I am trying to find a way to have all the links in the Iframe (not the entire page) open in a new window. I've tried a couple solutions with no luck. Is there a way I can target the iframe and use the HTML base tag?
Due to the Same Origin Policy, you can only modify the contents of an iframe if the domains and protocols match.
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.