Link to home
Start Free TrialLog in
Avatar of yerffoeg
yerffoegFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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.
Avatar of knightEknight
knightEknight
Flag of United States of America image

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');

}
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.
Avatar of yerffoeg

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your answer it saved me a lot of bother trying to work it out myself!

Dave.