Solved

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

Posted on 2004-08-20
5
313 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
Comment Utility
<A href="somepage.html#someAnchor" target="popupName" onclick="window.open('',this.target).focus();" >
0
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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

17 Experts available now in Live!

Get 1:1 Help Now