Solved

a second window for my browser links

Posted on 1997-08-12
16
196 Views
Last Modified: 2011-10-03
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>
0
Comment
Question by:timshank
  • 8
  • 3
  • 2
  • +3
16 Comments
 
LVL 10

Expert Comment

by:kollegov
Comment Utility
May be, you only need to close window before opening other one
New one will appear on desktop

0
 

Author Comment

by:timshank
Comment Utility
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.
0
 
LVL 1

Expert Comment

by:barakp
Comment Utility
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>
0
 

Author Comment

by:timshank
Comment Utility
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
0
 

Expert Comment

by:894359
Comment Utility
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?
0
 

Author Comment

by:timshank
Comment Utility
Could you please tell me how to insert the onClick event into the script? thanks
0
 
LVL 3

Expert Comment

by:mmoore
Comment Utility
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.

0
 

Author Comment

by:timshank
Comment Utility
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
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 3

Expert Comment

by:mmoore
Comment Utility
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?

0
 

Author Comment

by:timshank
Comment Utility
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
0
 
LVL 3

Expert Comment

by:mmoore
Comment Utility
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. :-)

0
 

Author Comment

by:timshank
Comment Utility
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
0
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 70 total points
Comment Utility
Okay Tim,

I have but all the code together for you and created two files, which from there you can change to suit any page.  The important thing is to insert

<BODY onBlur="close()">

instead of your normal <BODY> tag.

here is the first page (as you had originally:-

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">

function EXAMPLE_1() {

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

           }

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>


<BODY>

        <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>

</BODY>

</HTML>


and here is the test page which loads in the window of the first link - note the <BODY> tag

<HTML>
<HEAD>
<TITLE>Border Colour</TITLE>
</HEAD>

<BODY onBlur="close()">

Tim's Page in a window

</BODY>
</HTML>

Cheers

    Trevor

P.S. If you have any problems do not reject my answer (as it is correct) but post a comment (without grading answer).
0
 

Author Comment

by:timshank
Comment Utility
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.
0
 
LVL 5

Expert Comment

by:Trevor013097
Comment Utility
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.


0
 

Author Comment

by:timshank
Comment Utility
well, I finally figured it out. the onBlur works in Netscape but not in iexplorer, any suggestions?
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Summernote and form validation 10 38
Page not loading properly 15 39
Adding Extra Information box 4 24
What does this javascript do? 7 23
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now