473,396 Members | 2,098 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,396 software developers and data experts.

OnBlur firing when not expected.

Hello all...
I am working on an ASP.NET 2.0 application with VS2005 and VB. I have chosen
to use popup windows in some cases because it makes the user experience
better (according to all the users I have polled who will be using this
app).

In an attempt to keep the popup from disappearing behind the calling window,
I am adding the onblur="FocusMe():" event to the Body tag of the popup. I
really want onblur to react to any click outside the popup Window, but I
have read that the only place to put that event when trying to apply it to
the window is in the Body tag. BTW... FocusMe() just does window.focus();

Well I thought this would be a simple task and work just fine... after all,
doesn't everybody who uses popups have to deal with this issue? That's why I
also expected to find copious documentation on the subject if I ran into a
problem...not so.

Apparently when I click on any form input type control (text, select, etc.)
that is clearly within the Window and within the Body tags, the
window.onblur (body.onblur) event fires, and the input control does not
function. Not what I expected.

I then tried placing an OnClick event in the Body of the parent window...
which looks for an open popup and places focus back onto it. That allows
controls inside the popup to work, but fails if I click on certain controls
(like links) in the parent window.

I have looked in Javascript forums and books for answers and have not found
them yet. So I am posting here, since my development environment is ASP.NET
2.0.

Somebody please tell me there is an easy way to fix this problem, and I have
just not found it yet.

Thanks to all for your help.
May 2 '07 #1
10 2425
Not sure what is the problem you are trying to solve. Are you trying to
create an "always on top" window or a modal dialog ? Could it be acceptable
to create a div with the appropriate z-index order ?
"John Kotuby" <jo***@powerlist.coma écrit dans le message de news:
Oe**************@TK2MSFTNGP02.phx.gbl...
Hello all...
I am working on an ASP.NET 2.0 application with VS2005 and VB. I have
chosen to use popup windows in some cases because it makes the user
experience better (according to all the users I have polled who will be
using this app).

In an attempt to keep the popup from disappearing behind the calling
window, I am adding the onblur="FocusMe():" event to the Body tag of the
popup. I really want onblur to react to any click outside the popup
Window, but I have read that the only place to put that event when trying
to apply it to the window is in the Body tag. BTW... FocusMe() just does
window.focus();

Well I thought this would be a simple task and work just fine... after
all, doesn't everybody who uses popups have to deal with this issue?
That's why I also expected to find copious documentation on the subject if
I ran into a problem...not so.

Apparently when I click on any form input type control (text, select,
etc.) that is clearly within the Window and within the Body tags, the
window.onblur (body.onblur) event fires, and the input control does not
function. Not what I expected.

I then tried placing an OnClick event in the Body of the parent window...
which looks for an open popup and places focus back onto it. That allows
controls inside the popup to work, but fails if I click on certain
controls (like links) in the parent window.

I have looked in Javascript forums and books for answers and have not
found them yet. So I am posting here, since my development environment is
ASP.NET 2.0.

Somebody please tell me there is an easy way to fix this problem, and I
have just not found it yet.

Thanks to all for your help.

May 2 '07 #2
"John Kotuby" <jo***@powerlist.comwrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
Somebody please tell me there is an easy way to fix this problem, and I
have just not found it yet.
Is this a public Internet app or a closed intranet app...?
--
http://www.markrae.net

May 2 '07 #3
Thanks for the quick responses. I was busy looking into
window.showModalDialog function for the last couple hours and am having
trouble getting it to work in IE7.

It is a public internet application that requires authentication. The aspx
form displayed in the window must be filled out and submitted (posted back)
to allow creation of a Record entry (using the entered form values) in SQL
Server.

In essence I want the user to fill out the form before continuing back to
the parent window. I could just navigate to another aspx, and let the user
go back to the "parent" window to continue working. However, it is simpler
for the user to do repetitive tasks from the "parent" window if I just use a
"modal" popup.

BTW...This part of the application is available after the user logs in and
is authenticated. It is not part of the login.

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:ek**************@TK2MSFTNGP06.phx.gbl...
"John Kotuby" <jo***@powerlist.comwrote in message
news:Oe**************@TK2MSFTNGP02.phx.gbl...
>Somebody please tell me there is an easy way to fix this problem, and I
have just not found it yet.

Is this a public Internet app or a closed intranet app...?
--
http://www.markrae.net

May 2 '07 #4
I am trying to create a modal window in which the user fills out form
information, submits it, the window closes, and the user is back to the
parent window and can then repeat a similar task with any of possibly
hundreds of Repeater entries that might be present on that page.

I have to think about whether "always on top" would actually work better. I
have been reading about the window.ShowModalDialog function and that it has
trouble with posting back to the server. I have also been getting synatax
errors trying to create it.
------------------------------------------
function OpenNewWin(type)
{
if(type=='deck')
{ if(window.showModalDialog)
{
window.showModalDialog("/Search/NewDeck.aspx", window, "dialogHeight: 500px;
dialogWidth: 550px; dialogTop: 40px; dialogLeft: 40px; edge: Raised; center:
Yes; help: No; resizable: Yes; status: Yes;");
}
else
{
var
newdeck=window.open("/Search/NewDeck.aspx","newdeck","modal=yes,title=show,tool bar=0,location=0,status=0,menubar=0,scrollbars=1,r esizable=1,width=550,height=500,top=40,left=40");
popWin=newdeck; newdeck.focus();
}
}

if(type=='card') ........... and so on.
-------------------------------
I am getting the syntax error on the line beginning
window.showModalDialog("/Search/NewDeck.aspx", window, "dialogHeight:
500px ........

"Patrice" <http://www.chez.com/scribe/wrote in message
news:eY**************@TK2MSFTNGP06.phx.gbl...
Not sure what is the problem you are trying to solve. Are you trying to
create an "always on top" window or a modal dialog ? Could it be
acceptable to create a div with the appropriate z-index order ?
"John Kotuby" <jo***@powerlist.coma écrit dans le message de news:
Oe**************@TK2MSFTNGP02.phx.gbl...
>Hello all...
I am working on an ASP.NET 2.0 application with VS2005 and VB. I have
chosen to use popup windows in some cases because it makes the user
experience better (according to all the users I have polled who will be
using this app).

In an attempt to keep the popup from disappearing behind the calling
window, I am adding the onblur="FocusMe():" event to the Body tag of the
popup. I really want onblur to react to any click outside the popup
Window, but I have read that the only place to put that event when trying
to apply it to the window is in the Body tag. BTW... FocusMe() just does
window.focus();

Well I thought this would be a simple task and work just fine... after
all, doesn't everybody who uses popups have to deal with this issue?
That's why I also expected to find copious documentation on the subject
if I ran into a problem...not so.

Apparently when I click on any form input type control (text, select,
etc.) that is clearly within the Window and within the Body tags, the
window.onblur (body.onblur) event fires, and the input control does not
function. Not what I expected.

I then tried placing an OnClick event in the Body of the parent window...
which looks for an open popup and places focus back onto it. That allows
controls inside the popup to work, but fails if I click on certain
controls (like links) in the parent window.

I have looked in Javascript forums and books for answers and have not
found them yet. So I am posting here, since my development environment is
ASP.NET 2.0.

Somebody please tell me there is an easy way to fix this problem, and I
have just not found it yet.

Thanks to all for your help.


May 2 '07 #5
"John Kotuby" <jo***@powerlist.comwrote in message
news:u8**************@TK2MSFTNGP02.phx.gbl...
Thanks for the quick responses. I was busy looking into
window.showModalDialog function for the last couple hours and am having
trouble getting it to work in IE7.
Really? Works perfectly in IE7 for me... What specific problems are you
having...?
It is a public internet application
Ah - well that rules showModalDialog out, then, as that is supported only in
IE and the latest version of Safari...

May 2 '07 #6
Hi Mark,

I was having truoble getting the showModalDialog to run because I was
leaving the "argument" argument empty instead of passing something like
"window" which I am doing in the below example. Now it works fine.

Since it is actually a paid subscription site that is used for research
during business hours, we can stipulate IE if we want.
However, I saw a great article that showed me how to test for
showModalDialog in javascript...

{ if(window.showModalDialog)
{
window.showModalDialog("/Search/NewDeck.aspx", window, "dialogHeight: 500px;
");
}
else
{
var
newdeck=window.open("/Search/NewDeck.aspx","newdeck","modal=yes,title=show");
}

The modal=yes attribute works for newer Mozilla/Foxfire browsers. No excuse
not to use a newer browser for security...especially in business.

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:O0**************@TK2MSFTNGP05.phx.gbl...
"John Kotuby" <jo***@powerlist.comwrote in message
news:u8**************@TK2MSFTNGP02.phx.gbl...
>Thanks for the quick responses. I was busy looking into
window.showModalDialog function for the last couple hours and am having
trouble getting it to work in IE7.

Really? Works perfectly in IE7 for me... What specific problems are you
having...?
>It is a public internet application

Ah - well that rules showModalDialog out, then, as that is supported only
in IE and the latest version of Safari...

May 2 '07 #7
"John Kotuby" <jo***@powerlist.comwrote in message
news:OA**************@TK2MSFTNGP04.phx.gbl...
The modal=yes attribute works for newer Mozilla/Foxfire browsers.
Obviously you mean FireFox...

The modal=yes tab is completely unreliable. I have just tried it on a
variety of browser / platform combinations, and the only one it worked on
was Mozilla 1.7.13 for Windows.

It failed on all of the following:

FireFox 2.0.0.3 for Windows, Mac & Linux
Opera 9.20 for Windows, Mac & Linux
Netscape 8.1.2 for Windows
Netscape 7.2 for Mac & Linux
Mozilla 1.7.13 for Mac & Linux
Camino 1.0.4 for Mac
SeaMonkey 1.1.1 for Windows, Mac & Linux

May 2 '07 #8
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OA****************@TK2MSFTNGP02.phx.gbl...
It failed on all of the following:
I forgot to mention that it also failed on:

Epiphany 2.18.1 for Linux
Konqueror 3.5.6 for Linux
--
http://www.markrae.net

May 2 '07 #9
Mark,
You are indeed correct..
My error entirely. "Always test before you speak " is what I should
remember. Along with "Don't believe everything you read".

I don't want to be passing along bad informattion and I'm glad you called me
on it.

I have since seen other postings where for FireFox it is recommended to
feign pop-ups with absolute positioned <divelements (or other appropriate
elements), change either visibility attributes(which I have done in IE) or
z-order (something I havent even messed with yet).

The coders that code primarily for FireFox bad mouth IE for it's stupididy
in failing to understand simple css commands, while I say "why doesn't
firefox respect the modal attribute" .

I guess its all a point of view thing.

Even in IE I have found that PostBacks with modal or even modeless dialogs
present some problems. When just opening a child window without modality,
the postbacks appear in the same child window... which is what I want.

I am back to looking at the onblur event and how to tell when the mouse
pointer is outside of the child window or just pointing to a form element
within the child window. If that is easy to determine then I can use the
onblur event and just do nothing if the mousepointer is still in the child
window or call self.focus() top.focus() or window.focus() if it's not.
Another option is to (maybe) somehow disable the entire parent window when
creating the popup.

My other alternative is to feign a popup by creating a div or table inside
the original form and displaying it when necessary... but that would require
a LOT of new coding at this point, when the boss is screaming for results.

I can't believe such a simple thing can present such problems.. for me at
least. For now I must move on with other aspects of the application until I
find the right solution for the popups.

Thanks for your help...

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OA****************@TK2MSFTNGP02.phx.gbl...
"John Kotuby" <jo***@powerlist.comwrote in message
news:OA**************@TK2MSFTNGP04.phx.gbl...
>The modal=yes attribute works for newer Mozilla/Foxfire browsers.

Obviously you mean FireFox...

The modal=yes tab is completely unreliable. I have just tried it on a
variety of browser / platform combinations, and the only one it worked on
was Mozilla 1.7.13 for Windows.

It failed on all of the following:

FireFox 2.0.0.3 for Windows, Mac & Linux
Opera 9.20 for Windows, Mac & Linux
Netscape 8.1.2 for Windows
Netscape 7.2 for Mac & Linux
Mozilla 1.7.13 for Mac & Linux
Camino 1.0.4 for Mac
SeaMonkey 1.1.1 for Windows, Mac & Linux

May 3 '07 #10
"John Kotuby" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
I have since seen other postings where for FireFox it is recommended to
feign pop-ups with absolute positioned <divelements (or other
appropriate elements), change either visibility attributes(which I have
done in IE) or z-order (something I havent even messed with yet).
Yes indeed - which is what I used to do until Ajax...
The coders that code primarily for FireFox bad mouth IE for it's stupididy
in failing to understand simple css commands, while I say "why doesn't
firefox respect the modal attribute" .
IE6 and earlier versions were really, really, non-compliant - IE7 is much,
much better... As for modal dialogs, Apple clearly think they're a valid
piece of functionality to support as they've built them into their latest
Safari browser.
Even in IE I have found that PostBacks with modal or even modeless dialogs
present some problems. When just opening a child window without modality,
the postbacks appear in the same child window... which is what I want.
<base target="_self" /takes care of that...
I am back to looking at the onblur event and how to tell when the mouse
pointer is outside of the child window or just pointing to a form element
within the child window. If that is easy to determine then I can use the
onblur event and just do nothing if the mousepointer is still in the child
window or call self.focus() top.focus() or window.focus() if it's not.
Again, you'll encounter cross-browser incompatibilities with that...
Another option is to (maybe) somehow disable the entire parent window when
creating the popup.
Which is what Ajax does:
http://ajax.asp.net/ajaxtoolkit/Moda...odalPopup.aspx
My other alternative is to feign a popup by creating a div or table inside
the original form and displaying it when necessary... but that would
require a LOT of new coding at this point, when the boss is screaming for
results.
If you don't want to use Ajax, there are tons of examples of this type of
modal "dialog" on the net...
--
http://www.markrae.net

May 3 '07 #11

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

Similar topics

2
by: Eric | last post by:
Hello, I'm having trouble with a bit of code that is both validating and updating fields on the fly. Here's something similar to my code: ----------- <script> function validate(field) { var...
9
by: Roger Withnell | last post by:
Tearing hair out time! Simple attached page shows the problem. http://www.brilley.co.uk/TestFocusSelect.htm Using a function to test if too many characters have been keyed in to a textarea....
6
by: rob | last post by:
Hi I'm trying to create a "roll-up" effect when a window loses focus and then "roll-down" when it regains focus. This statement works properly with every browser I can get my hands on EXCEPT...
2
by: Heiko Vainsalu | last post by:
Hi Hope somebody knows how to solve this one. *The Situation* A traditional situation where HTML form inputs are checked... (if simplified then it would look something like this) <form...
1
by: neil S via DotNetMonster.com | last post by:
I have a custom control with a textbox and dropdown list. The dropdown list is hidden and acts as a data source for the textbox. When the user enters text in the textbox, an onKeyup event is...
4
by: josh.dutcher | last post by:
I'm trying to set up a simple "change your password" form. I've got an AJAX process that is checking the new password the user enters against their current password to make sure they're changing...
5
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any...
1
by: Duncan | last post by:
Hi all, I'm tearing my hair out on this! I have a simple ASP.NET 2 page with a TextBox control, in the PreRender I set ClientSide events:- Response.Attributes.Add("onchange",...
2
by: John Kotuby | last post by:
Hi all, I am integrating some 3rd party grids into a large ASPX form page in VS 2008 using VB. I have 4 different grids on the page. The object is to not allow the user to leave a grid if...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.