Solved

Javascript New Window and Focus

Posted on 2002-06-17
6
161 Views
Last Modified: 2012-08-13
I want to be able to open a second window when I click on a link and have the second window take the focus. (usually happens by default)

When the user returns to the first window without closing the second and clicks on another link, I want that link to open in the second window and take the focus.

I can do all of this except for the second window taking the focus when the second link is clicked.

Here's what I've got right now:

<PRE>

<P><A HREF="firstpage.html" TARGET="myWindow">First Page</A></P>
<P><A HREF="secondpage.html" TARGET="myWindow">Second Page</A></P>
</PRE>
0
Comment
Question by:bhlang
  • 4
  • 2
6 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 7084181
there are two ways to do it ...
in both firstpage.htm and secondpage.htm, do this:

<BODY onLoad='self.focus();'>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7084188
the second way is to try to do it in the link:

<P><A HREF="firstpage.html" TARGET="myWindow"
   onClick='window.open(this.href).focus();return false;'>First Page</A></P>
<P><A HREF="secondpage.html" TARGET="myWindow"
   onClick='window.open(this.href).focus();return false;>Second Page</A></P>
0
 

Author Comment

by:bhlang
ID: 7084189
That wshuld work fine in most cases. I should have mentioned that firstpage.html and secondpage.html MAY be PDF documents instead of HTML documents. What would I use on those when the Acrobat plug in is set to open the documents in the browser instead of in the application?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 33

Accepted Solution

by:
knightEknight earned 100 total points
ID: 7084196
oops, forgot the target:


<P><A HREF="firstpage.html" TARGET="myWindow"
  onClick='window.open(this.href,this.target).focus();return false;'>First Page</A></P>

<P><A HREF="secondpage.html" TARGET="myWindow"
  onClick='window.open(this.href,this.target).focus();return false;'>Second Page</A></P>

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7084198
ok, if they are PDFs, then try the method above instead.
0
 

Author Comment

by:bhlang
ID: 7089900
It worked as promised! Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Diminish Pop-up  in 3 seconds 7 52
Html value of radio 14 31
javascript - insert into js doc help 2 25
JavaScript Sort Ordering and Choice Limiting 5 27
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…
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…

808 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