473,811 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2227
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.javas cript 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.javas cript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptT oolbox.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.javas cript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptT oolbox.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.
Unfortunatel y, 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.javas cript 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
4966
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 that I can interrogate ? I would like to find a better way of doing the following. I have a window (call it Win) that creates a new window (call it Win2) using window.open().
2
4229
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 windows to the front (top) in Netscape, IE and Opera. However, this command does nothing when you access the web page through AOL, even though they say this is IE. Once a window is behind (blurred), I have been unable to bring it back to the front...
31
2860
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 www.any.xy an setting the focus to "extern". But when I go return to "main" without closing "extern", a click to an other link (e.g. www.2nd_any.xy) on "main" does not setting the focus to "extern".
19
31079
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(). The problem is that after the reload, it brings you right to the top of the page. When I click 'refresh" on the original page, it brings me back to the original viewing position. Is there a way to duplicate this in from the popup window. Also,...
4
3609
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 alpha 2) only brings it to the top if the window 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 Mozilla/Firefox that I can ensure that this
1
2756
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 Sources window ... ( means expandable, means expanded, is a checked checkbox, "QmsDataLayer" is the name of the referenced data layer.)
13
22179
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 Mozilla/Firefox that I can ensure that this window comes to the top? Thank you for your help
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.