473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

window.focus() brings source code into focus

I'm trying to figure out a workaround to a minor annoyance that I'm
coming up with while coding a site. I've got some keyboard shortcuts
set up for the site via javascript, and when I press escape, it's set
to hide several divs on the page, and remove focus from a link.
Unfortunately, I don't know which link will have focus, so I can't
just blur a particular element (that I'm aware of) since I won't know
which element it is. I got it working by using window.blur() followed
by window.focus(). The problem is that if I have a source code window
open, the window.focus() function brings the source code on top of
everything else and it takes focus. I don't see this being a huge
issue for users, but it's a real pain while I'm developing the site.
Does anyone know why it does this, and, more importantly, a workaround
for it?
Thanks in advance.
Jan 8 '08 #1
4 2184
Spizzat2 said the following on 1/8/2008 9:02 AM:
I'm trying to figure out a workaround to a minor annoyance that I'm
coming up with while coding a site. I've got some keyboard shortcuts
set up for the site via javascript, and when I press escape, it's set
to hide several divs on the page, and remove focus from a link.
Unfortunately, I don't know which link will have focus, so I can't
just blur a particular element (that I'm aware of) since I won't know
which element it is. I got it working by using window.blur() followed
by window.focus(). The problem is that if I have a source code window
open, the window.focus() function brings the source code on top of
everything else and it takes focus. I don't see this being a huge
issue for users, but it's a real pain while I'm developing the site.
Does anyone know why it does this, and, more importantly, a workaround
for it?
Thanks in advance.
When you blur the window, in Windows, it will go to the next application
in the active list. Alt-Tab and you will find your source window the
next "in line". It isn't explicitly picking the source code window to go
to, it just happens to be the next in line.

Try focusing an element in the page and then blur that element instead
of the window.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 8 '08 #2
On Jan 8, 1:20 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Spizzat2 said the following on 1/8/2008 9:02 AM:
I'm trying to figure out a workaround to a minor annoyance that I'm
coming up with while coding a site. I've got some keyboard shortcuts
set up for the site via javascript, and when I press escape, it's set
to hide several divs on the page, and remove focus from a link.
Unfortunately, I don't know which link will have focus, so I can't
just blur a particular element (that I'm aware of) since I won't know
which element it is. I got it working by using window.blur() followed
by window.focus(). The problem is that if I have a source code window
open, the window.focus() function brings the source code on top of
everything else and it takes focus. I don't see this being a huge
issue for users, but it's a real pain while I'm developing the site.
Does anyone know why it does this, and, more importantly, a workaround
for it?
Thanks in advance.

When you blur the window, in Windows, it will go to the next application
in the active list. Alt-Tab and you will find your source window the
next "in line". It isn't explicitly picking the source code window to go
to, it just happens to be the next in line.

Try focusing an element in the page and then blur that element instead
of the window.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
It still brings up the source code window regardless of source code's
position in the Alt-Tab list, but thanks for the potential solution.
I'll give it a shot and see how it works for my situation.
Jan 9 '08 #3
On Jan 9, 9:27 am, Spizzat2 <Spizz...@gmail.comwrote:
On Jan 8, 1:20 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Spizzat2 said the following on 1/8/2008 9:02 AM:
I'm trying to figure out a workaround to a minor annoyance that I'm
coming up with while coding a site. I've got some keyboard shortcuts
set up for the site via javascript, and when I press escape, it's set
to hide several divs on the page, and remove focus from a link.
Unfortunately, I don't know which link will have focus, so I can't
just blur a particular element (that I'm aware of) since I won't know
which element it is. I got it working by using window.blur() followed
by window.focus(). The problem is that if I have a source code window
open, the window.focus() function brings the source code on top of
everything else and it takes focus. I don't see this being a huge
issue for users, but it's a real pain while I'm developing the site.
Does anyone know why it does this, and, more importantly, a workaround
for it?
Thanks in advance.
When you blur the window, in Windows, it will go to the next application
in the active list. Alt-Tab and you will find your source window the
next "in line". It isn't explicitly picking the source code window to go
to, it just happens to be the next in line.
Try focusing an element in the page and then blur that element instead
of the window.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

It still brings up the source code window regardless of source code's
position in the Alt-Tab list, but thanks for the potential solution.
I'll give it a shot and see how it works for my situation.
Well, I got a solution that works using your method, so thank you for
that. I'm still confused about the cause of the problem, though. I
wonder if the source code page is considered a child window of the
parent, so when it brings it into focus, it just grabs the child-most
window (if that makes any sense).
Oh well, it works. I'm happy.
Jan 9 '08 #4
Spizzat2 said the following on 1/9/2008 10:45 AM:
On Jan 9, 9:27 am, Spizzat2 <Spizz...@gmail.comwrote:
>On Jan 8, 1:20 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>>Spizzat2 said the following on 1/8/2008 9:02 AM:
I'm trying to figure out a workaround to a minor annoyance that I'm
coming up with while coding a site. I've got some keyboard shortcuts
set up for the site via javascript, and when I press escape, it's set
to hide several divs on the page, and remove focus from a link.
Unfortunately, I don't know which link will have focus, so I can't
just blur a particular element (that I'm aware of) since I won't know
which element it is. I got it working by using window.blur() followed
by window.focus(). The problem is that if I have a source code window
open, the window.focus() function brings the source code on top of
everything else and it takes focus. I don't see this being a huge
issue for users, but it's a real pain while I'm developing the site.
Does anyone know why it does this, and, more importantly, a workaround
for it?
Thanks in advance.
When you blur the window, in Windows, it will go to the next application
in the active list. Alt-Tab and you will find your source window the
next "in line". It isn't explicitly picking the source code window to go
to, it just happens to be the next in line.
Try focusing an element in the page and then blur that element instead
of the window.
It still brings up the source code window regardless of source code's
position in the Alt-Tab list, but thanks for the potential solution.
I'll give it a shot and see how it works for my situation.

Well, I got a solution that works using your method, so thank you for
that. I'm still confused about the cause of the problem, though.
When you say "Source code window", are you referring to Notepad or some
other app that you use, or, an editing product where you preview it in
the program and then you can use the source code window?

I wonder if the source code page is considered a child window of the
parent, so when it brings it into focus, it just grabs the child-most
window (if that makes any sense).
Oh well, it works. I'm happy.
It could very well be that it is simply focusing the last window to have
focus before the current one. What an OS does when you blur a window is
up to the OS and not a lot that MS does makes any sense.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 9 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dom Nicholas | last post by:
Hi, My question is this : how do I detect from another window which didn't create a new window whether it exists ? For example, is there a window-id's container of some sort that hangs around...
2
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing...
31
by: Benno Bös | last post by:
If I use the following construct in the frame "main" for a link to an extern site: <A HREF="http://www.any.xy" TARGET="extern"> the Browser is creating the window "extern", loading the page...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
4
by: Csaba Gabor | last post by:
Up until a few weeks ago, javascript code like window.open("http://mydomain.com", "windowName"); would always bring my new or reused window to the top, with focus. Lately, Firefox (Deer park...
1
by: dbuchanan | last post by:
Hello, A section in Data Sources window is mystifying to me. In the case of my code the Data Sources window shows my references to the data access layer. First here is what I see in my Data...
13
by: tochiromifune | last post by:
Hello The window.open method brings my window to the top only if it is new. If it's being reused, the window does not come to the foreground (with IE 6 it does). Is there a new way in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.