Connecting Tech Pros Worldwide Help | Site Map

Problem with onBlur="window.close()" and MS IE 6

Peter Pagé
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi,

I've got a window with a "<body onBlur="window.close()"> tag that keeps
closing prematurely. It happens when the user clicks on text inside a table
in the same window. Apparently IE decides that the <body> no longer has the
focus if the <table> within the <body> has it. Firefox handles the page
correctly as does MS 5.

This may be one of those "security features" that came along with Windows XP
SP2, but wherever it came from, it's a real pain in the you-know-what. Does
anyone know of a work-around for this?

Thanks,
Peter


kaeli
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Problem with onBlur="window.close()" and MS IE 6


In article <tQh3e.48743$tO5.880879@wagner.videotron.net>,
ppage@alcor.concordia.ca enlightened us with...[color=blue]
>
> This may be one of those "security features" that came along with Windows XP
> SP2, but wherever it came from, it's a real pain in the you-know-what. Does
> anyone know of a work-around for this?
>[/color]

A guess:

Use the standards compliant doctype?
Seems like it matters...

http://msdn.microsoft.com/workshop/a...jects/body.asp
As of Internet Explorer 6, when you use the !DOCTYPE declaration to specify
standards-compliant mode, the body object can obtain its size from its
content, or you can set its size explicitly=3Flike a div object, for example.
In standards-compliant mode, the html element represents the entire surface
onto which a document's contents can be rendered. When the !DOCTYPE
declaration does not specify standards-compliant mode, and with earler
versions of Internet Explorer, the body object represents the entire surface
onto which a document's contents can be rendered. The size of the body object
cannot be changed and is equal to the size of the window. Margins you set on
this object are rendered inside the border and scrollbars of the object.

--
--
~kaeli~
What do they use to ship styrofoam?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

RobB
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Problem with onBlur="window.close()" and MS IE 6


Peter Page wrote:[color=blue]
> Hi,
> I have a window with a <body onBlur="window.close()"> tag that is[/color]
closing[color=blue]
> prematurely. The problem occurs when the user clicks on text in the[/color]
window[color=blue]
> that is within a table. Apparently IE decides that if the <table>[/color]
has[color=blue]
> focus, then the <body> doesn't, and so it should close the window.[/color]
This[color=blue]
> may be one of those new Win XP SP2 "security features" since Firefox
> handles the code correctly and so does a MS IE v.5 (Mac version).
>
> Has anyone found a workaround for this new 'feature'?
>
> Thanks,
> Peter[/color]

Can't say I've dealt with that particular 'feature' - but there's a
reasonable workaround for the need to set focus on text inputs in such
a window without closing it. Use a timer:

var blurtimer = null;
var closeOK = true;

self.onblur = function()
{
blurtimer = setTimeout('if(closeOK)self.close()', 100);
}

You then have the delay period to block the closer script from any
onfocus handler:

<table onfocus="closeOK=false;" onblur="closeOK=true;">

[untested]

Peter Pagé
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Problem with onBlur="window.close()" and MS IE 6


Thanks for the suggestion.; it sounded like the solution, but apparently it
isn't. Any other suggestions would be more than welcome at this point -
I've spent the whole day on alternatives and nothing seems to work.

A simplified version of the code for the page, which is generated by PHP
when a user submits a form, looks like this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
</head>

<body onblur="javascript:window.close()" >

<table>
<tr>
<td>
<p>SAVAGE, Anne</p>
<p>Born: Montreal Quebec, 1896</p>
<p>Died: Montreal Quebec, 1971</p>
</td>
</tr>
</table>

</body>
</html>
I get the same results whether I use the DOCTYPE tag or not. I've even
tried each of the following declarations, all with the same results; the
window closes if I click on the displayed text.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
" http://www.w3.org/TR/html4/loose.dtd">
Peter

P.S. Not that it changes the behaviour of the page, but in the application
I'm writing, the name "SAVAGE, Anne" is actually a link that will bring up a
more complete record about that person. This has no direct bearing on the
problem, but does restrict the range of possible solutions.

-----------------------------

"kaeli" <tiny_one@NOSPAM.comcast.net> wrote in message
news:MPG.1cb77102f01b0baa98a431@nntp.lucent.com...[color=blue]
> In article <tQh3e.48743$tO5.880879@wagner.videotron.net>,
> ppage@alcor.concordia.ca enlightened us with...[color=green]
>>
>> This may be one of those "security features" that came along with Windows
>> XP
>> SP2, but wherever it came from, it's a real pain in the you-know-what.
>> Does
>> anyone know of a work-around for this?
>>[/color]
>
> A guess:
>
> Use the standards compliant doctype?
> Seems like it matters...
>
> http://msdn.microsoft.com/workshop/a...jects/body.asp
> As of Internet Explorer 6, when you use the !DOCTYPE declaration to
> specify
> standards-compliant mode, the body object can obtain its size from its
> content, or you can set its size explicitly=3Flike a div object, for
> example.
> In standards-compliant mode, the html element represents the entire
> surface
> onto which a document's contents can be rendered. When the !DOCTYPE
> declaration does not specify standards-compliant mode, and with earler
> versions of Internet Explorer, the body object represents the entire
> surface
> onto which a document's contents can be rendered. The size of the body
> object
> cannot be changed and is equal to the size of the window. Margins you set
> on
> this object are rendered inside the border and scrollbars of the object.
>
> --
> --
> ~kaeli~
> What do they use to ship styrofoam?
> http://www.ipwebdesign.net/wildAtHeart
> http://www.ipwebdesign.net/kaelisSpace
>[/color]


Peter Pagé
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Problem with onBlur="window.close()" and MS IE 6



Woo-hoo! I had to modify it a lot to get it to work with my particular
problem, but using a timer was the key.

Thank you very much!
Peter



"RobB" <ferndoc9@hotmail.com> wrote in message
news:1112390090.509529.262800@g14g2000cwa.googlegr oups.com...[color=blue]
> Peter Page wrote:[color=green]
>> Hi,
>> I have a window with a <body onBlur="window.close()"> tag that is[/color]
> closing[color=green]
>> prematurely. The problem occurs when the user clicks on text in the[/color]
> window[color=green]
>> that is within a table. Apparently IE decides that if the <table>[/color]
> has[color=green]
>> focus, then the <body> doesn't, and so it should close the window.[/color]
> This[color=green]
>> may be one of those new Win XP SP2 "security features" since Firefox
>> handles the code correctly and so does a MS IE v.5 (Mac version).
>>
>> Has anyone found a workaround for this new 'feature'?
>>
>> Thanks,
>> Peter[/color]
>
> Can't say I've dealt with that particular 'feature' - but there's a
> reasonable workaround for the need to set focus on text inputs in such
> a window without closing it. Use a timer:
>
> var blurtimer = null;
> var closeOK = true;
>
> self.onblur = function()
> {
> blurtimer = setTimeout('if(closeOK)self.close()', 100);
> }
>
> You then have the delay period to block the closer script from any
> onfocus handler:
>
> <table onfocus="closeOK=false;" onblur="closeOK=true;">
>
> [untested]
>[/color]


Closed Thread