By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <tQ********************@wagner.videotron.net>,
pp***@alcor.concordia.ca enlightened us with...

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?


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

Jul 23 '05 #2

P: n/a
Peter Page wrote:
Hi,
I have a window with a <body onBlur="window.close()"> tag that is closing prematurely. The problem occurs when the user clicks on text in the window that is within a table. Apparently IE decides that if the <table> has focus, then the <body> doesn't, and so it should close the window. This 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


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]

Jul 23 '05 #3

P: n/a
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" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <tQ********************@wagner.videotron.net>,
pp***@alcor.concordia.ca enlightened us with...

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?


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

Jul 23 '05 #4

P: n/a

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" <fe******@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Peter Page wrote:
Hi,
I have a window with a <body onBlur="window.close()"> tag that is

closing
prematurely. The problem occurs when the user clicks on text in the

window
that is within a table. Apparently IE decides that if the <table>

has
focus, then the <body> doesn't, and so it should close the window.

This
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


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]

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.