|
|
Subject:
HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
Category: Computers > Programming Asked by: askreceive-ga List Price: $5.00 |
Posted:
09 May 2002 12:00 PDT
Expires: 16 May 2002 12:00 PDT Question ID: 14024 |
Subject: what is the code to LEAVE FRAMES (not target="_top" variations) to WHATEVER page is open in second frame? This HTML question will be super easy to answer for someone who knows the answer. I'm just having a hard time tracking it down. I use FrontPage 2000, so my HTML programming ability is limited. QUESTION CONTEXT: I have a two-frames set-up where the top frame contains navigation information, and the bottom frame is a given page within a target site. I need to have a 'leave frames' hyperlink in the top frame that will take the person to the second page by itself, whatever that page is at the time. The target="_parent" or target="_top" commands are not what I'm looking for, because they require that a URL be specified in the link. Two examples of where I want to use this feature are: http://www.sterlingdallan.com/jjdewey/offsite/books/immortal.htm and http://www.sterlingdallan.com/jjdewey/offsite/themes/beast.htm The purpose of the top frame is to give the users a route back to the main site. But within the bottom frame will be a wide array of pages. I want the user to be able to click on the "leave frames" button (defined by a single code), and have the current page in the bottom frame open alone into their browser. That generic code is what I want. I'm sure there is a simple solution to this. I just haven't been able to find it. I'm guessing that the solution is going to look something like this (the following code is an actual working sample used for another application). <a onclick="href='http://web.archive.org/web/*/'+location.href" href="http://www.greaterthings.com">Page History</a> Clicking on this link opens an archive.org version of whatever page is open at the time on my site. Very simple code for a fairly complex operation. There has to be something like this for the "leave frames" function I'm seeking. I just can't find it. Your help would be appreciated. Thanks | |
|
|
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
Answered By: joey-ga on 09 May 2002 13:42 PDT Rated: |
There is a way to do it, but with the security-conscious nature of many modern browsers, it will only work if the site in the bottom frame is within the same domain as the top frame and the frameset. This is because the standard security settings of modern browsers don't allow frames to access variables relating to other "remote" frames or windows (this is to prevent sites from "tracking" you). Supposing both the top and bottom frames are within your domain, you may use the following tag: <a href="#" onClick='parent.location.href=parent.main.location.href;return false;'>close top frame</a> This assumes you've named the bottom frame "main", which I believe you've done. Unfortunately, if the bottom frame is in a different domain and the user hasn't lowered his browser's security settings, the only solution you have is to use a hardcoded URL in the link with a "_top" target. This unfortunately won't take them back to where they've last surfed, only the first page you linked them to. Notice that About.com does this [http://classiclit.about.com/gi/dynamic/offsite.htm?site=http%3A%2F%2Fwww.uic.edu%2Fjaddams%2Fhull%2Fja_bio.html]. They link to off-site pages with a top frame, and offer an option to "turn off this top frame", but if you've clicked through several links in the bottom frame, it loses your position in the site, taking you back to the first page to which it linked. I'm sorry that this doesn't offer you an ideal solution, but I hope I've adequately explained your options to you. Let me know if you need anything else. --Joey | |
| |
| |
|
askreceive-ga
rated this answer:
Didn't resolve my problem, but did tell me that the problem is probably currently unresolvable, which is more than what I knew. Darn it. |
|
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: cheese-ga on 09 May 2002 12:21 PDT |
My Researcher account hasn't been actived yet, so I'll have to post this as a comment. I would just use Javascript, and make the link like this: <a href="javascript:parent.location.href=parent.mainframe.location.href">close top frame</a> where "mainframe" is the name of the frame with the content. |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: askreceive-ga on 09 May 2002 14:58 PDT |
I tried this and it didn't work. I used the following code: <a href="javascript:parent.location.href=parent.main.location.href">close top frame</a> The target frame (different domain location) is labeled "main." |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: askreceive-ga on 09 May 2002 15:02 PDT |
http://www.jjwritings.com/leave_frames.htm Instructions on How to Close Down Frames and Not Loose Your Place Here is how to close out frames without loosing your place. - Right click on the page you wish to view outside of frames. - Click on "properties." One of the pieces of information shown will be the "Address(URL)." - Select this by blocking it out (left click at the beginning, hold down mouse while you move to the end of the address, then release the left-click button). - Press CTRL-C [copy] (push down the "Ctrl" button on your keyboard, and hold it down while pressing the "c" key.) This copies that text into the clipboard of your computer (you don't see anything happening). - Place your cursor in the browser address box of your browser. Delete the current address. - Press Ctrl-V to paste the contents of the clipboard into the browser address box. - Hit "Enter" on your keyboard. This will take you to the page currently open in the frames, breaking you out of the frames you are currently in. We webmasters wish we could just make a link for you in which all you have to do is click on it and the top frame disappears, making the contents in the bottom frame the only contents in the browser. Unfortunately, without lowering security settings, current browsers do not allow such a procedure when the target frame is on a different domain because it would enable tracking of sites visited. There are ways to create a link that will break you out of frames, but a URL must be specified, and you are almost sure to loose your place. Instructions composed by Sterling D. Allan on behalf of JJWritings.com, May 9, 2002. |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: askreceive-ga on 09 May 2002 15:14 PDT |
I submitted this dialogue to Microsoft's "wish list" for integration into future browser software. |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: mmi-ga on 09 May 2002 15:49 PDT |
It can be done as long as the page in question does not have a script that forces it into frames such as the msdn site - if you can load a page into the lower frame then they can get the url of it (whether it is from your site or external) - from there it is a short step to say: top.location = top.bottomframename.location |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: cheese-ga on 09 May 2002 16:17 PDT |
Since the pages are not in the same domain, you can do this: Have the navigation in the top frame link like this: <a href="http://yoursite.com/page.html?otherurl">site</a> where "otherurl" is http://...whatever, the link you really want. Then, in the navigation frame code, add to the body tag <body onLoad="show()">. Then, in between <head> and </head>, insert <script language="Javascript"> function show() { if (location.href.indexOf("?")>-1) { var u = location.href; u=u.substring(u.indexOf("?"),u.length); document.otherframe.location = u } } </script> Lastly, make the link to close the top frame like this: <a href="javascript:parent.location.href=location.href.substring(location.href.indexOf('?'),location.href.length)">close top frame</a> |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: askreceive-ga on 09 May 2002 18:30 PDT |
Perhaps I didn't do them right, but none of these suggestions worked. (1) I placed the following code in the head section of the frames definition page; and in the top frame page (the first then the second) <script language="Javascript"> function show() { if (location.href.indexOf("?")>-1) { var u = location.href; u=u.substring(u.indexOf("?"),u.length); document.otherframe.location = u } } </script> with the following code for the "close top frames" link: <a href="javascript:parent.location.href=location.href.substring(location.href.indexOf('?'),location.href.length)">close top frame</a> (2) I tried <a href="javascript:top.location=top.main.location">close top frame</a> (3) I tried <a href="javascript:top.location.href=top.main.location.href">close top frame</a> What would help, along with these suggestions is if you could give me a URL that I could go to see them in working operation. Please, no more suggestions until you can do that. You're wasting my time. |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: mmi-ga on 09 May 2002 19:16 PDT |
you might try asking this question in a web development forum that specializes in javascript issues, such as http://webxpertz.net/forums/ or http://sitepointforums.com/ - you need to register to ask a Q (it's free), but I bet you'll get a good answer :-) |
Subject:
Re: HTML Code: 'Leave Frames'-Close first of two frames and open second frame only.
From: tracker-ga on 10 May 2002 12:30 PDT |
Dear askreceive, It seems that you want to allow surfers to navigate freely on off domain sites but I would imagine that you would like to maintain a way for them to return to your site ... ? May I suggest that you target all off site links to a new window of their own ... Just a little "food" for thought. -Tracker- |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |