Javascript pop-up windows don't self-close on losing focus

RESOLVED WORKSFORME

Status

()

Core
DOM: Core & HTML
RESOLVED WORKSFORME
17 years ago
17 years ago

People

(Reporter: Mark Annand, Assigned: saari (gone))

Tracking

Trunk
mozilla1.0
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

17 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9+) Gecko/20010522
BuildID:    2001052204

'Green' links in that web page lead to javascript pop up windows. These are
intended to close themselves when they lose focus, but don't.

The javascript behind this is in 'Additional information' ... apologies if its
to blame ...

 


Reproducible: Always
Steps to Reproduce:
1.Load page
2.Select green link
3.Select window that's not pop up - pop up persists rather than closing itself.

Actual Results:  Pop up still open

Expected Results:  Pop up was intended to close (the intention, and behaviour
with IE5 and Netscape 4+)

The javascript code is in an external file, but here's a copy in case this helps.

// The following invoke pop up windows,
// but different sizes and places ...
// Values or graphics are passed for the function to display or a text string ...

function openWin(graphic,title)
{
// open new window with name 'picture'.

picture= open("", "diagram",
"scrollbars=no,width=170,height=180,screenX=540,screenY=330,left=540,top=330");
// open document and write to it
picture.document.open();

picture.document.write("<HTML><HEAD><TITLE>");
picture.document.write(title);
picture.document.write("</TITLE></HEAD><BODY onBlur='self.close()'>");
picture.document.write("<CENTER>");
picture.document.write('<IMG SRC="');
picture.document.write(graphic);
picture.document.write('">');
picture.document.write("</CENTER>");
picture.document.write("</BODY></HTML>");
// close the document - (not the window! I've asked that to shut itself ...)
picture.document.close();
}
function openWin1(graphic,title)
{

illustration= open("", "diagram",
"scrollbars=no,width=393,height=276,screenX=175,screenY=100,left=175,top=100");
// open document and write to it
illustration.document.open();

illustration.document.write("<HTML><HEAD><TITLE>");
illustration.document.write(title);
illustration.document.write("</TITLE></HEAD><BODY onBlur='self.close()'>");
illustration.document.write("<CENTER>");
illustration.document.write('<IMG SRC="');
illustration.document.write(graphic);
illustration.document.write('">');
illustration.document.write("</CENTER>");
illustration.document.write("</BODY></HTML>");
// close the document - (not the window! I've asked that to shut itself ...)
illustration.document.close();
}

function openWin2(htmlstring,title)
{

webpage= open("", "htmlstring",
"scrollbars=yes,width=280,height=320,screenX=175,screenY=100,left=175,top=100");
// open document and write to it
webpage.document.open();

webpage.document.write("<HTML><HEAD><TITLE></TITLE>");
webpage.document.write("</HEAD>");
webpage.document.write("<BODY BGCOLOR=#FFFFAA onBlur='self.close()'>");
webpage.document.write("<FONT FACE=verdana COLOR=#339933>");
webpage.document.write(htmlstring)
webpage.document.write("</FONT>");
webpage.document.write("</BODY></HTML>");
// close the document - (not the window! I've asked that to shut itself ...)
webpage.document.close();
}

function openWin3(graphic,title)
{
// open new window with name 'picture'.

picture= open("", "diagram",
"scrollbars=no,width=293,height=245,screenX=175,screenY=120,left=175,top=120");
// open document and write to it
picture.document.open();

picture.document.write("<HTML><HEAD><TITLE>");
picture.document.write(title);
picture.document.write("</TITLE></HEAD><BODY onBlur='self.close()'>");
picture.document.write("<CENTER>");
picture.document.write('<IMG SRC="');
picture.document.write(graphic);
picture.document.write('">');
picture.document.write("</CENTER>");
picture.document.write("</BODY></HTML>");
// close the document - (not the window! I've asked that to shut itself ...)
picture.document.close();
}

function openWin4(graphic,title)
{
// open new window with name 'picture'.

picture= open("", "diagram",
"scrollbars=no,width=440,height=468,screenX=175,screenY=75,left=175,top=75");
// open document and write to it
picture.document.open();

picture.document.write("<HTML><HEAD><TITLE>");
picture.document.write(title);
picture.document.write("</TITLE></HEAD><BODY onBlur='self.close()'>");
picture.document.write("<CENTER>");
picture.document.write('<IMG SRC="');
picture.document.write(graphic);
picture.document.write('">');
picture.document.write("</CENTER>");
picture.document.write("</BODY></HTML>");
// close the document - (not the window! I've asked that to shut itself ...)
picture.document.close();
}




/*

*/
// The End

Comment 1

17 years ago
Browser, not engine --> DOM.

Note: I can't even get the popup windows to come up in the first place.
Using Mozilla debug builds 2001-05-23 Linux, WinNT. Works fine in NN4.7.
Assignee: rogerl → jst
Status: UNCONFIRMED → NEW
Component: Javascript Engine → DOM Level 0
Ever confirmed: true
QA Contact: pschwartau → desale
(Reporter)

Comment 2

17 years ago
Build ID 2001052204 again but on Win 95 this time - same behaviour as before -
window comes up but not interested in self closing.

Best wishes

Mark

Comment 3

17 years ago
The pop up window will self close if you click on it to set focus. Focus doesn't
seem to be properly set upon pop up. Try clicking on the pop up window before
you click away and it will close.
The problem here seems to be that the *inner* window object (i.e. the content
window, not the XUL window object)that has the onblur handler never gets focus
when the window is opened unless you click in it, because of this we never fire
the onblur on the *inner* window since it was never focused.

Over to saari, getting this fixed for mozilla0.9.3 would be very nice.
Assignee: jst → saari
Keywords: mozilla0.9.3
(Assignee)

Comment 5

17 years ago
Uh... okay... changing that behavior in the general case would be dangerous to
say the least. And we get into issues with frame sets, who do you focus first?
The way apps do this is that they choose what to focus and do it explicitly. Is
the JS window launching code specialized enough to add an explicit focus call in
there?
(Assignee)

Updated

17 years ago
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.0
(Assignee)

Comment 6

17 years ago
This seems to have gotten fixed along the way. Marking worksforme
Status: ASSIGNED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.