Closed Bug 82551 Opened 23 years ago Closed 23 years ago

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

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME
mozilla1.0

People

(Reporter: annand.mark, Assigned: saari)

References

()

Details

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
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
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
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
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?
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.0
This seems to have gotten fixed along the way. Marking worksforme
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.