Close other site div from iframe - php

I have iframes on my website which point to content on a different domain. This content is meant to be re-purposed and is ad supported. There is 3-5 ad's on each page, each with their own close button. I believe they are all in one div, id="bannerfloat22". Is there a way to make a close button but target the div inside the frame? The codes I've tried only seem to work if the div is on MY page.
Example: I use this iframe on my page.
<iframe src="http://coolsport.tv/kiwi25.html" name="25" width="650" height="480"></iframe>
Thanks.

If the iframe url is a different domain, then no - there is nothing you can do. If the iframe url is from your site's domain, then yes - you can target the DOM inside the iframe.

In short... No. Javascript from one domain cannot have any control over a DOM from another. This is a security issue - eg to stop a hidden iframe stealing login details for another site
For more information, read up on the same origin policy

Related

How to forcefully click on a button in an iframe using jQuery or PHP?

How to forcefully click on a button in an iframe using jQuery or PHP?
example
<iframe src="www.google.com"></iframe>
I want to press the button or anchor tag in that iframe.
And also change anchor tag target -> '_self'
Expanding on "not possible"...
The "Same origin policies" apply: your only way of communicating with the contents of iframes that come from another [domain|subdomain|protocol|port] is through the postMessage API, which of course requires the other part (the document inside the iframe) to listen to your messages. This means that unless you're a google employee with access to the search frontend, this won't be possible.
If you work at google and want to press a button forcefully, I recommend standing with your foot on your mouse: your weight will help push it with more strength.
Not possible. Blocked by Browsers for security concerns.
On serverside you could use CasperJS to click some stuff inside an iFrame. See here
How do I access an iframe from CasperJS?

iframe and header location issue

I am using an iframe under which another small application is running on. In one certain page of the iframe, I try to redirect the url to parent's index page. But if I am using header('location:fullpath/index.php'). then it is redirecting to the mentioned page, but within the iframe. I need it will be opened beyond the iframe. Could you please help me to fix up this issue?
If you don't want to use javascript and you have control over the target page, you can put this metatag at the top of the target page and it should open in a new window.
<META HTTP-EQUIV="Window-target" CONTENT="_blank">
Here is a list of the other CONTENT options you can try as I'm not certain what beyond the iframe means.
Same Frame -_self
Whole Page -_top
New Window -_blank
Parent Frame-_parent

Can I load a domain in my iFrame and when you click a link, it opens in the parent window, not the iframe?

Similar to Stumbleupon, if you load random domains (ones that I do not own) and want to have the links within that page not just change within the iframe, but change on the parent url.
If that's hard to understand here's more layman terms:
URL: mywebsite.com/reddit.com
opens iframe on my website showing: reddit.com
click link within the iframe (showing reddit.com).
rather than it loading the new page in the iframe, can it load in the parent window at mywebsite.com/reddit.com/newlink
which would then open the iframe in my website, but would allow me to track what URL is being view and thus allowing me to perform my site-specific functionality.
Thanks!
in short, it cant happen. external sites are made to open links relative to their sites. there is no way to accomplish this.
you can set the link target to _top. <a href='www.someothersite.com' target='_top'>Link</a>
edit: Sorry, mis-read something. You can not edit the page on the other site through the iframe to change the target of the links. This is why on places like google images or stumbleupon they have an "X" in the corner that takes you to the page in the iframe.
If you could modify external pages, that would be a major phishing security risk as anyone could then make a page that is just an iframe to your bank but collects whatever you type into the username/password boxes.
In the old days if you made a page with frames you could specify what section your links took you to. Modifying links that aren't under your control is possible but rather a task and a half.
To use frames you could specify your target= within your tag. Each frame is named on creation to make it easy.
That's an old approach. Hope it helps

how can i Hide element of iframe in wordpress page template

I am displaying the iframe in wordpress page template. In iframe src i have pased the external site url. The Problem is that i am not able to to hide the logout link in the iframe.
I have tried the below mention code :-
frame = document.getElementById("toolkit-iframe");
frame.document.getElementById("top-nav-links").style.display='none';
OR
frame = document.getElementById("toolkit-iframe");
frame.contentDocument.getElementById("top-nav-links").style.display='none';
I have not got any success to hide the link of logout. Can anybody can help me. i will be verymuch thankfull.
There is no direct way to manipulate the content of an iframe, that's not hosted on your domain due to security issues.
However, there is a "hacky" workaround for your problem:
Place your iframe in a container div. Div gets relative positioning. Place another div in the container and set it to absolute positioning and perhaps a positive z-index. Set width and height and position of this hiding div according to the logoutlink size and position.
You can not inject javascript into a page from another domain, even within an iframe.

How to access child iframe elements from a parent javascript page?

In my page i have iframe code. When i click particluar link that i frame window enabled.it is a form.when i submit the form i get some hidden field values.how can i access those values in my parent page?.
Since your iframe src= a complete url, and not a relative path (i.e: /app/appsignup.jsp) I am going to assume this Iframe exists at another IP or domain than the original page. If this assumption is correct, then you are not going to be able to modify the Iframe's DOM due to cross site scripting security rules in most browsers.
If the parent site, and child iframe exist on the same top level domain, then you can use document.getElementById("iframe_id")
Edit to answer second question:
You can add an onLoad event to the iframe, and so long as the iframe only has 1 form, and the page only changes when submitted, and this is where you want to be redirected.
Here is an example, but know this will redirect the first time and not work!
What you will want to do is put a function in there, and then in the .js for that function check for the second onLoad...
<iframe name="signUp" id="signup" src="10.80.32.9:8080/app/appsignup.jsp"; width="650" height="500" onLoad="window.location('/index.html');">
You will not be able to access the iframe if it's on a different domain and/or port, as yours seem to be. The Same Origin Policy will prevent that.
There may be a workaround, depending on your use case. Maybe add some more details.

Categories