Opening a new window then open in old window?

My HTML has a frameset front page with a left frame containing a menu that opens pages in the main (right) frame using

<A HREF="" TARGET="MAIN_RIGHT"..>

where MAIN_RIGHT is the name of the main frame on the page. This works fine until I open a product window with the following javascript function:

function openwin(url)
{
      window.name="mainwin"
      window.open(url, "prodwin", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=400');
      
}

After I have opened one of these product windows the links in my menu frame open another new window instead of opening the page in the MAIN_RIGHT frame. Why does it do this and how do I correct it?

Cheers,

Dave.
LVL 1
yerffoegAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
knightEknightConnect With a Mentor Commented:
I'd have to say a qualified yes to your question about NS and IE.  I am unable to try it both, but as far as I can tell by looking at the code, it should work!  Glad to help.

function openwin(url)
{
   top.open(url, "prodwin", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=400');
}
0
 
knightEknightCommented:
Try this:

function openwin(url)
{
  top.open(url, "prodwin", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=400');

}
0
 
knightEknightCommented:
The problem is that in your function you are renaming the current window to "mainwin", and therefore the frame name changes, so any further references to it must open a new window.  The code above should eliminate that problem for you.
0
 
yerffoegAuthor Commented:
I didn't realise it was that simple, I got the code from a colleague who didn't really understand how he had done it and I am not too good at javascript. Before I give you the points can you answer another question for me - will this work on both IE4+ and NN4+? Post your response as an answer and I'll accept it.
0
 
yerffoegAuthor Commented:
Thanks for your answer it saved me a lot of bother trying to work it out myself!

Dave.
0
All Courses

From novice to tech pro — start learning today.