/    Sign up×
Community /Pin to ProfileBookmark

How to Close Frame in Frameset w/out Losing Page

What can Diigolet do but Bing and Google Image search cannot do?

Close their frame and remember the page you were on.

[FONT=”Arial Black”][SIZE=”4″]Background:[/SIZE][/FONT]
I am making a music player for a client that will stay on the page no matter what page he is going to and not be interrupted by the user’s browsing. I decided to implement frames. Now the hard thing is how to close the frame the music player is on without disturbing the page that the user was on. I have tried a few little things with no success at all.

[FONT=”Arial Black”][SIZE=”4″]Request:[/SIZE][/FONT]
A javascript code in or along side of a link html tag. Such as…

[CODE]<a href=”javascript:CODE” target=”_top”>[X]</a>[/CODE]

[I][B]or[/B][/I]

[CODE]<script>
function closeframe() {
CODE
}
</script>
<a href=”javascript:closeframe()” target=”_top”>[X]</a>[/CODE]

Please help. Thanks.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Devin_TauthorJul 09.2009 — Alright, I figured it out. To close a frame and stay on the URL of the main frame, I had to get the proper value for the URL of the main frame as it changes. Once I found that out, I set the top frame URL equal to that URL. So simple, but I've never seen this code anywhere. Heck, like I said, Google and Bing haven't figured it out... maybe there's a browser issue?

Whatev's, here it is...

[CODE]
<script>
var mainloc = window.parent.frames["NAMEOFFRAME"].document.location
function clsefrme() {
window.top.document.location = mainloc
}
</script>
<a href="#" onclick="javascript:clsefrme();return false">[X]</a>
[/CODE]
Copy linkTweet thisAlerts:
@Devin_TauthorJul 09.2009 — This also works (just tried it in MF 1.5):

[CODE]
<a href="javascript:window.top.document.location=window.parent.frames['NAMEOFFRAME'].document.location">[X]</a>
[/CODE]
×

Success!

Help @Devin_T 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 5.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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