Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7938
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <3007137.SPkdTlGXAF@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Wed, 02 Nov 2011 21:25:44 +0100 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 8Bit |
| 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 |
| MIME-Version | 1.0 |
| Lines | 58 |
| NNTP-Posting-Date | 02 Nov 2011 21:25:45 CET |
| NNTP-Posting-Host | c5e37fd8.newsspool2.arcor-online.net |
| X-Trace | DXC=OFeINTggc4CC4i^e1BZ=_HA9EHlD;3YcB4Fo<]lROoRA8kF<OcfhCOK4LhWYJTITMLDZm8W4\YJNL;?f@h5gMfbLBIlHSWN<J<O98GJHKG5O`E |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.javascript:7938 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
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