how can i Hide element of iframe in wordpress page template - php

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.

Related

populating iframe with content from POST

I need to display content that was posted from the previous page within iframe. Is it possible?
The content will have HTML tags.
The reason why I need iframe, because it will also have reference to CSS. If I just echo it on page, then it will make problems with CSS style of the main webpage. The only sollution I have found is to use iframe.
Why not just correct your CSS?
FWIW, I don't think you are able to POST data to anything inside an iFrame, especially if you don't have control over the iFrame content.
Iframes link to a URL.
So if you can save the post data into a file on your server and then use ajax or refresh the page to inject the url to that file on the iframe, then you will be sorted.

Close other site div from iframe

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

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

Auto scroll down iframe

How can I get an iframe such that when it loads up, it loads up with the page inside scrolled down by a fixed amount (say 100px)?
I have so far:
<iframe src="http://news.bbc.co.uk/1/hi/uk/7459669.stm" scrolling="no" width=500px height=500px></iframe>
but it loads up with the bbc.co.uk page inside at the top left when I actually want it to load up scrolled part way down (that is the page inside the iframe scrolled down, not the page containing the iframe).
Anyone know how to do this?
Its not exactly what you are looking for but you could set the URL to load scrolled to a particular element if you know that an element with that ID will always be on the page.
Something like this:
http://news.bbc.co.uk/2/hi/uk_news/7459669.stm#mediaAsset
HTH
You can not do this. Browser security restrictions will prevent you from accessing the "inside" of that frame completely. If the frame src was from the same domain as the containing page, then you could add an onload handler that set myiframe.contentDocument.body.scrollTop = 100;.
Genrally I Do Specify marginheight attribute on iframe for this
<iframe src='url' marginheight='100px'>
You can also use marginwidth attribute to move inner page left side
for more information checkout this link
http://www.w3schools.com/tags/tag_iframe.asp
I hope Thats Help

Categories