/    Sign up×
Community /Pin to ProfileBookmark

Automatically close iframe

Hi All,

I like a very simple script that automatically closes an iframe on my page.

Here is the iframe:

[CODE]iframe id=”fr1″ src=”http://blablabla.com” height=”1200″ width=”70%”></iframe>[/CODE]

So now, how can I close the iframe with some javacoding?

Thanks πŸ™‚

to post a comment
JavaScript

5 Comments(s) ↴

Copy linkTweet thisAlerts:
@mrhooSep 20.2009 β€”Β var who=document.getElementById('fr1');

who.parentNode.removeChild(who);
Copy linkTweet thisAlerts:
@cromagnonauthorSep 20.2009 β€”Β Thanks,

I have tried, but now the page is just blank. I like to remove the frames, so the URL (in this case Google.com) is on the page but now without the frames.

Here is the code is use:

[CODE]

<body>

<iframe id="fr1" src="http://www.google.com" height="1200" width="70%"></iframe>

<p>
<script type="text/javascript">
var who=document.getElementById('fr1');
who.parentNode.removeChild(who);
</script>
</p>

</body>
</html>[/CODE]


What to do?
Copy linkTweet thisAlerts:
@cromagnonauthorSep 22.2009 β€”Β Ok guys, I know this problem is really boring for experts, but are you sure you cant help me? :o
Copy linkTweet thisAlerts:
@jamesbcox1980Sep 22.2009 β€”Β Ok, so you're wanting to simulate the right-click and "Show only this frame". You want the original content to go away and the iframe to become the main window, is that correct? Question is, do you mind reloading the page? If not, it's as simple as [CODE]window.location=document.getElementById('fr1').src;[/CODE]
Copy linkTweet thisAlerts:
@cromagnonauthorSep 22.2009 β€”Β Exactly what I was looking for. Thanks! :p
Γ—

Success!

Help @cromagnon 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,
)...