Welcome to WebmasterWorld Guest from 54.205.140.252

Forum Moderators: open

Message Too Old, No Replies

Remove a Frame with Javascript?

Removing the top frame of a 2 frame page

     
4:01 pm on Mar 8, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:May 1, 2002
posts:52
votes: 0


I have a question...I have a page that is put together by an outside company (2). It is a list of company (1)'s products. The company (1) wants to have a top frame with their logo to remind people of that the list they are viewing belongs to them. The problem is that visitors can navigate from the list to the web and I want to give them the option of closing the top frame no matter what page the bottom frame has loaded. I only have html access to the top frame so the script would have to be in there. *The page is opened via JS.

Ex:

<top frame> my page w/logo - html access
<bottom frame> our list on diff. server - no html access

So, can I have a piece of script that closes the top frame no matter what the bottom frame has loaded in it?

Thanks!

5:52 pm on Mar 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


Sure you can ;)

<a href="javascript:top.location.href=bottom.location.href">Remove frame</a>

Replace "bottom" with the actual name of the frame :)

9:18 pm on Mar 8, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:May 1, 2002
posts:52
votes: 0


That is odd, I can't make it work (IE OSX). I have the script in the top frame, and the bottom frame's source is the remote file. Any ideas?
10:40 pm on Mar 8, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 27, 2002
posts:125
votes: 0


Try:

<a href="javascript:self.location.href=window.bottom.location.href">
Remove frame</a>

or

<a href="window.bottom.location.href" target=_top>
Remove frame</a>

12:09 am on Mar 9, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:May 1, 2002
posts:52
votes: 0


I must be having issues. What a day! I have no clue.
12:32 am on Mar 10, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:May 1, 2002
posts:52
votes: 0


Just to be sure, I don't need any script in the frameset, I can just put the script in the page that makes up the top frame, right? God I hate frames.
5:16 am on Mar 10, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


Right, you just put the script in the top frame.

However, the advice you're being given assumes that you have assigned name="bottom" to the bottom frame. You should replace "bottom" with whatever name you have actually assigned to the bottom frame...and you assign that name attribute in the frameset document.

Also note that "top" does not refer to the name of the top frame, so you do not change that. "Top" is a dedicated javascript word for the top level window - the parent of all contained frames.