Solved

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

Posted on 2004-08-20
5
315 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
javascript: add id amounts 5 46
how can i test my code? 1 34
jqury 17 28
Pass asp session variable to a js function in an asp script 6 19
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

776 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