Click to See Complete Forum and Search --> : new window focus
wynton_ca
12-04-2003, 01:18 PM
Here's the deal,..
I have a footer link that opens into a new window (target="_new"). That all works fine and dandy. Once that window is opened, it remains open and any other link from the parent window displays in the new window. My problem is that I cannot get the child window to come into focus on clicks after the initial.
anyone have any ideas?
thanks,
w
David Harrison
12-04-2003, 02:17 PM
Try adding this to the sources of the new window:
<body onload="window.focus();">
scrmbledeggs
12-05-2003, 01:47 PM
I am having a similar problem--I have numerous pop-ups on one page. As the user clicks each one I want the previous pop-up to be replaced by the new pop-up. I had tried the code you mentioned:
<body onload="window.focus();">
but it doesn't work for me because my pop-ups are different sizes and some of the info gets cut off at the bottom. Any ideas?
David Harrison
12-05-2003, 02:00 PM
If you want to replace a pop-up, you would need to close the old one and open the new one. To do this, simply name all of your pop-up's the same thing and when you run the function have this as the first line:
window_name.close();
scrmbledeggs
12-05-2003, 02:32 PM
Thanks for your help.
Do you place that code on the main page or the pop-up?
Also, when I give all the pop-ups the same name I have that problem with the text getting cut off in the pop-up window. Some of my pop-ups contain two lines; some of them contain entire paragraphs. I don't want to use scroll bars either because I don't like the way they look.
David Harrison
12-05-2003, 03:20 PM
OK, so I lied a little. There is a little bit of extra script that I included so that it would work properly.
The event handlers on the links to open the windows looks like this:
onclick="opwin('Phrase 1','Lavalamp is great!!!',100,100);return false;"
The first bit 'Phrase 1' is the title of the pop-up window.
The second bit 'Lavalamp is great!!!' is the message.
The first number is the width and the second number is the height.
Another type of event handler might look like this:
onclick="opwin('Phrase 3',preprogrammed_phrase[0],300,300);return false;"
The preprogrammed_phrase[0] bit refers to an array in the script tags within the head of the document for if you have slightly longer messages to write.
This is the array as it stands:
var preprogrammed_phrase=new Array();
preprogrammed_phrase[0]="I'm sure that scrmbledeggs is OK as well.";
preprogrammed_phrase[1]="Not\nforgetting<br>wynton_ca\nin\nall\nthis."
\n creates a new line in the source code and <br>, well, you should know what that does.
scrmbledeggs
12-08-2003, 08:03 AM
thanks again for all your help, lavalamp. i did find a solution before i received your post, however. i just added the following code to the body tag of each pop-up window:
onBlur=self.close();
this is in addition to the <body onload="window.focus();"> code that you had suggested earlier. the pop-ups now work fine and each one replaces the next in the appropriate-sized window. it works in both netscape and i.e.
thanks for your help and for creating specific examples--maybe i can use that code next time!!