/    Sign up×
Community /Pin to ProfileBookmark

Closing an iframe with external page from within the iframe

Hi guys,

I’m really hoping someone can help as I’ve searched high and low for an answer to this….

I have some js on website1 that opens up an iframe which contains a page from website2. What I need to do is add a close link to the page on website2 that will close the iframe.

Sounds simple but I’m really struggling to do this without affecting website1.

Please, please – any help will really be appreciated!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@mrhooSep 05.2006 — Closing the window that is in the iframe doesn't close the iframe-

You can't 'close' an iframe-

You can hide it, or remove it from the document tree, or change its src to a blank new window,

but you can only do these from the contained window if it shares the same server domain as the parent window.
Copy linkTweet thisAlerts:
@mbaxauthorSep 05.2006 — Thanks for your reply.

So the only possible way that I can make the external iframe "disappear" when clicked in is to make the external page remove its own content and take on an invisible background?


If you go to http://www.scripts.com/php-scripts/chat-scripts/php121-web-instant-messenger/ and hover over the linked word "PHP" then an external advertisment will appear with a close option - I presume this isn't iframe then but DOM or something?

thanks
Copy linkTweet thisAlerts:
@mbaxauthorSep 06.2006 — In fact - is it possible to create an iframe within an iframe so that the first is from the same site and the second from the external site, so the first can be closed (which encompasses the second)?

Or am I just talking garbage?
×

Success!

Help @mbax spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...