Solved

onload=window.focus doesn't work when calling page with anchor in url

Posted on 2004-08-20
5
314 Views
Last Modified: 2008-03-03
Hi,

I have several popup windows on my site and if one is already popped up and in the background, when it is called with an anchor in the url the page stays in the background and ignores the body tag with window focus in it. Is there a simple solution for this problem.

Thanks
0
Comment
Question by:Chris_Granger
  • 4
5 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 11854886
<A href="somepage.html#someAnchor" target="popupName" onclick="window.open('',this.target).focus();" >
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 11854896
assuming the popup exists already, that will put focus on the popup before it moves to the anchor ... otherwise it will open the popup and then load the page.  However, I forgot to return true from the onclick:

<A  href="somepage.html#someAnchor"  target="popupName"  onclick="window.open('',this.target).focus();return true;" >
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 11854905
to clarify the onclick, I am swapping the double and single quotes around:

onclick='window.open("",this.target).focus();return true;'
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 250 total points
ID: 11855086
also, if the popup exists already, then the anchor by itself should be sufficient:

<A  href="#someAnchor"  target="popupName"  onclick='window.open("",this.target).focus();return true;' >
0
 

Author Comment

by:Chris_Granger
ID: 11858316
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Debugging step-by-step Jquery/Javascript 6 57
Full Screen problem when auto scale IFRAME 2 65
Replace &lt; with < 14 56
Having problem getting this to work 2 19
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

920 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

14 Experts available now in Live!

Get 1:1 Help Now