View Full Version : Open page in frames with Open in New Window

01-13-2003, 06:28 AM
Dear experts,

I am new to all this and try to make my personal web page look a little more professional :o

My home pages uses 2 frames like this:
<frameset rows="38,*" framespacing="0" border="0" frameborder="0">
<frame name="header" scrolling="no" target="main" src="http://www.mydomain.com/home page/header.html" marginwidth="0" marginheight="0">
<frame name="main" src="http://www.mydomain.com/home page/body.asp" scrolling="auto" noresize>

<p>This page uses frames, but your browser doesn't support them.</p>


The 1st frame is a header with hyperlinks to the main pages on my site map. It is my menu bar. The 2nd frame is my home page. With this, anytime a user uses a hyperlink, the windows open under the header frame. So they keep the menu bar on top of all pages.

My problem is when they click on "open in new window. Then the 1st frame is not called and they loose the menu bar.

Any idea how to (simply...;) ) keep the 1st frame called on "Open in New Window" event?


01-13-2003, 08:35 AM
Okay, I'm not sure I understand exactly wat the problem is so i'll just post my presumptions, if that's not what you looking for, post the link, or the code for the pages necessary (not just the page setting up the frames).

Solution 1:
For your links: <a href="goingtosomepage.html" target="main">Link</a>

Solution 2: If you want to open a new window:

<a href="javascript:void()" onclick="window.open('somelink.html','_body');">Link</a>

Hope that helps.


01-13-2003, 02:53 PM
Hello duniyadnd

Thanks for your response and your time.
I am not sure this is what I want though... :confused:

here is my URL: http://www.mydomain.com/main.html

When you go there you see my home page. There is a menu bar on top of it (the 1st frame in my code example above)

If you click on any link (on the page or the menu bar), you go to another page. The top frame (menu) stays on top.

If you use your right click and "Open in New Window", the page opens but without the menu bar that was on the top frame.

Thanks for your help.


01-13-2003, 03:13 PM
That's the problem when you use frames. Your pages can get out of their frameset.
Here's a thread about a script that keeps them in there:

01-13-2003, 04:17 PM
Joh6nns solution mentioned is a very elegant, yet not really simple solution; alternatively, you could make a seperate frameset for each content page with the same menu document in every first frame and link to these framesets, cancelling out part of the advantages (!) of using frames.
By the way: if you take a look a some of the better known professional sites you'll rarely find frames... ;)

01-13-2003, 06:36 PM
I have been searching with keywords to try to find such information. Was probably not using the right keywords then...:(

I will definitively give it a try.
No big deal anyways, it is just my personal web site... :p
And I agree about the comment on the pros: they don't use frames. But I was not crazy about putting javascripts in all my pages. Might have to to fix this issue though. I'll see...

You guys are great. Thanks for the time spent on this for me.:thumbsup:


01-13-2003, 06:51 PM
you could disable right clicking on the top frame, but that doesn't help, cause anyone can just press shift with the mouse button to get the links in a new page.

But yeah, the solution which mccookie gave is the right one, but if you want to avoid using javascript altogether, you might contemplating forgetting about this problem altogether, or you could remove frames and make it in a table format.

If you worried that you going to keep changing your menu system, you can use server side includes (SSI) which is supported by most hosts. In thought process this is very similar to frames, but with a twist.

eg. <!-- virtual include="/somelink.html" --> -> I think its something like that, I haven't used it in a while. Anyway, now the file that will call it is on every single page I have. somelink.html will have all the information for my menu, all i have to do is call that page on every page. If I make a single change in somelink.html, then all the changes will occur for the pages that call it. Also, another thing which I never knew about, but took me about two months to figure out (no one I knew used SSI back then), is that all the files that you use to call in another page using SSIs should have an extension of *.shtml

Hope that gives you new ideas on solving your problem.


01-15-2003, 06:44 AM
For information, I looked at the options offered by Joh6nns and friends.
Pretty cool!:)
However I invented a little of my own...
I took the simple one proposed my Mr J that reloads the frame into the main frameset:

function LoadFrame(){
if (self.location.search){
parent.framename.location = location.search.substring(1,location.search.length);
onload = LoadFrame
// -->

and in the pages:

if (self == top){
var url = self.location;
self.location = "frameset.htm?" + url;
// -->

But instead of using the default page (problem with dial up modems mentionned by Gordo), I use a special "default" frameset that loads a blank empty page below my menu bar. Much faster to load than my original default page. Does not matter since it is replaced by the page I want to load anyways.

Thanks a lot for your help. I would not have found this by myself!
:thumbsup: :thumbsup: