Link to home
Start Free TrialLog in
Avatar of timshank
timshank

asked on

a second window for my browser links

I was given a script for having a small browser window pop up when a link was clicked, and the link was put into the second window. It works fine except when the second window is minimized it remains on the taskbar even after another link is selected, the window will update but it remains minimized, I would like it if the smaller window would come back "on top" anytime a link is selected so it is visible.

Here is the script I have:

</script><script language="JavaScript">
                   function EXAMPLE_1() {
                       window.open('heb1317.html','EANITHING','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=250,height=100');
                   }
                   </script><script language="JavaScript">
                   function EXAMPLE_2() {
                       window.open('LINK','EANITHING','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=275,height=400');
                   }
                   </script>

                   <a href="javascript:EXAMPLE_1()"
                   onmouseover="window.status='SCROLLING TEXT'; return true">LINK HERE</a>
                   <br>
                   <br>
                   <a href="javascript:EXAMPLE_2()"
                   onmouseover="window.status='SCROLLING TEXT'; return true">LINK HERE</a>
Avatar of kollegov
kollegov

May be, you only need to close window before opening other one
New one will appear on desktop

Avatar of timshank

ASKER

That is true, however I want it so that anyone can use the web page, without my giving instructions about closing the second window when they are done. If someone minimizes it they wont know to maximize the window again to look at the new link. It works if they close the window, but if they dont it dosen't work.
You could use the same trick of closing the window before opening it

<SCRIPT LANGUAGE="Javascript">
<!--

<script language="JavaScript">
function EXAMPLE_1() {

EANITHING.close();       window.open('heb1317.html','EANITHING','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=250,height=100');

}
</script>
<script language="JavaScript">
function EXAMPLE_2() {

EANITHING.close();       window.open('LINK','EANITHING','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=275,height=400');

           }
</script>
The closeing of the second window would work fine. However when I run this script I get an error stating that EANITHING is undefined in lines 9 and 14 (EANITHING.close(); window.open) Could you fix this for me and resubmit it please?

Thanks
Do you mean you  want the minimized window to reappear on the screen.... Won't an onClick event in the parent window and set the target=top work?
Could you please tell me how to insert the onClick event into the script? thanks
On your small window do
<BODY onBlur="close()">
This will cause the window to close as soon as the user
does anything else. The next time you need it,
you can launch a new pop-up.

yes, that may very well work also but once again I dont know where to insert it into my script, or out of my script to get it to work. I keep coming up with embeded object errors or syntax errors, not sure where else in my page to put it. Could you help me with that? Thank you
I'm not sure if I understand your question, the 'embeded object
errors' sound like a different issue to me. I think we
are addressing your question of "smaller window would come back "on top"". So, I am saying, put <BODY onBlur="close()">  into
 heb1317.html. As for "window.open('LINK','EANITHING',..."
I am a bit mystified as to what you are trying to do here.
I assume that you by LINK, you mean 'any valid html url'
Your not expecting this to do something to heb1317 are you?

I'm not sure where to put any of this in the java script. I think I have exausted my options. Yes the LINK is refering to any valad url. the heb1317 is just something I was experimenting with and forgot to change. It is what I had linked to so that html file would come up in the second browser window. All I'm trying to do is set up a page where links will come up in a smaller browser window, and anytime a link is chosen it will come up in the smaller window and the smaller window will also come up on top. I dont need to use the code I have above, I just need something that will accomplish this. Thanks
Ok, I think I understand. The problem is terminology. You are
saying "... links will come up ...". I think you mean ".. page
requested by the link will come up ...". You are saying
that you main page will have links on it, and when one of
those links is clicked, you want the resultant page to come
up in a small window. This could be any page on the net,
not necessairly one you authored. Right? In that case, since
you did not author the page in the small window, you can not
use the <BODY onBlur="close()">, you just take what you are
given. JavaScript has no control over ( or knowledge of )
if a window is minimumized or not. All that you can do is
open a window or close it. If they have minimumized the window,
you cannot maximumize it. The only thing you can do is
to close the window and open another one. You may be able to
set the onBlur attribute of your pop-up window concurrent
with creating it. If you can do this, that would mean that
as soon as the user clicks on anything other than the small
window, the small window would trigger the onBlur condition
which you set to close(). I don't know the exact syntax
for doing this, and I am not jumping up to look it up because
1)You may not like this solution even if it does work.
2)You may not understand what I am saying, so you don't
   know if you like it or not.
3)75 points is a little low and I really don't get anything
  out of this except knowing that I helped somebody.

If you think the solution is what you want and if you make this
150 points I will come up with the code to do this.

Another option is to reject my answer and that will make it
open again for somebody else. Maybe somebody has a better
answer than me. :-)

well, sorry but I still cant get the body tag to work, I am the author of the linked documents. Proboably something I'm doing wrong I'm sure, and I have gone with something else in the mean time but I would still love to know how it's done. Anybody else have any suggestions? Believe it or not I get a big kick out of answering questions also, but unfortunatly I am just not the one to answer anyone's Java questions :) thanks anyway
ASKER CERTIFIED SOLUTION
Avatar of Trevor013097
Trevor013097

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
ok I did that. I posted the page at

http://www.cvn.net/~timshank/test/2windows.html

 it is almost working. it seems to want to bring the second linked document to the top but after that it wont bring the first linked document to the top. Perhaps you could look at what I am talking about, I cant see where I made a mistake but I dont put it past myself to make one. I thought the onblur close would cause the smaller window to close. Can I add a background color in the same tag without messing up the onBlur? Thank you for your help.
The reason that this is happening is because when you try to click on the second link in the main browser window it is not actually in focus but the small window is.  The browser jumps straight to the link and bypasses closing the small window.  There is no way AFAIK to get around this.

I thought about using a setTimeout function call which would in effect give the browser a pause and time to close the smaller window before proceeding with the next.  However this had no joy because in order to tell it to pause you need to call a function and by that time it is too late.

The only thing is to point out that click anywhere outside the window except one of the links will cause the smaller window to close.


well, I finally figured it out. the onBlur works in Netscape but not in iexplorer, any suggestions?