Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7938
| Message-ID | <3007137.SPkdTlGXAF@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2011-11-02 21:25 +0100 |
| Subject | Re: Second window |
| Newsgroups | comp.lang.javascript |
| References | <4eafd7ad$0$6898$e4fe514c@news2.news.xs4all.nl> <1542790.qVoOGUtdWV@PointedEars.de> <4eb19d6a$0$6851$e4fe514c@news2.news.xs4all.nl> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
Tom de Neef wrote:
> "Thomas 'PointedEars' Lahn" <PointedEars@web.de> wrote:
>> You will have to use the same window name so that window.open() returns a
>> reference to the Window instance.
>>
>> As it is, your approach is flawed. document.write() will always
>> overwrite the content if the document has been loaded, but it will not
>> automatically close the output stream (you need document.close() for
>> that). window.open() will always replace what you might have written with
>> document.write() before.
>>
>> You should check if `secondWindow' refers to a Window (`secondWindow
>> converts to true) that is not closed (`closed' property is false), and
>> only call window.open() if neither is the case. Feature-test the focus()
>> method before you call it then, and catch any exceptions the call might
>> still throw.
>
> Thank you. But...
>
> function load2ndWindow(query) {
> if (secondWindow && !secondWindow.closed) secondWindow.clear();
> secondWindow = window.open(query,"Support", ...);
> }
>
> Loading the query results from the server may take some time. I want to
> avoid the situation where the user sees obsolete previous data in the
> support window.
I did not think of that. Your approach is sound then if you close the
output stream. However, you might want to write a complete HTML document
then, as I am not sure that all browsers would automatically wrap the text
in one. And never have a textual empty document; this is not user-friendly.
But see below.
> There are three situations to consider:
> […]
> c) a support window exists but (due to reloading of the main page) the
> global secondWindow has value null. What happens now is: the support
> window gets the focus and shows obsolete data while waiting for the new
> data to arrive from the server.
>
> This last situation I want to avoid. Is there a way to associate the
> variable secondWindow with an existing window, other than via window.open?
No, but there is another possibility: You can focus an existing popup window
only when its content has been loaded, preferably in the `load' listener of
the new support document's body (`onload' attribute value).
HTH
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Second window "Tom de Neef" <tdeneef@qolor.nl> - 2011-11-01 12:27 +0100
Re: Second window Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-01 14:50 +0100
Re: Second window "Tom de Neef" <tdeneef@qolor.nl> - 2011-11-02 20:43 +0100
Re: Second window "Tom de Neef" <tdeneef@qolor.nl> - 2011-11-02 20:51 +0100
Re: Second window Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-02 21:25 +0100
Re: Second window Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-02 21:35 +0100
Re: Second window "Tom de Neef" <tdeneef@qolor.nl> - 2011-11-02 23:23 +0100
csiph-web