Connecting Tech Pros Worldwide Forums | Help | Site Map

FAQ Topic - How do I open a new window with javascript?

FAQ server
Guest
 
Posts: n/a
#1: Nov 20 '06
-----------------------------------------------------------------------
FAQ Topic - How do I open a new window with javascript?
-----------------------------------------------------------------------

New windows can be opened on browsers that support the
« window.open » function and are not subject to the action of any
pop-up blocking mechanism with code such as:-

if(window.open){
wRef = window.open("http://example.com/page.html","windowName");
}

http://www.infimum.dk/HTML/JSwindows.html


===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://www.jibbering.com/faq/.
The FAQ workers are a group of volunteers.


Dr J R Stockton
Guest
 
Posts: n/a
#2: Nov 22 '06

re: FAQ Topic - How do I open a new window with javascript?


In comp.lang.javascript message
<45624188$0$49208$14726298@news.sunsite.dk>, Tue, 21 Nov 2006 00:00:02,
FAQ server <javascript@dotinternet.bewrote:
Quote:
>-----------------------------------------------------------------------
>FAQ Topic - How do I open a new window with javascript?
>-----------------------------------------------------------------------
>
>New windows can be opened on browsers that support the
>‹ window.open › function and are not subject to the action of any
>pop-up blocking mechanism with code such as:-
>
if(window.open){
wRef = window.open("http://example.com/page.html","windowName");
}

Perhaps it would be worth adding to that code a minimal statement to
write
into a specific element

wRef.document.getElementById("X").innerHTML = "Z" // to <p ID=X>

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm- also batprogs.htm.
Elegie
Guest
 
Posts: n/a
#3: Nov 23 '06

re: FAQ Topic - How do I open a new window with javascript?


Dr J R Stockton wrote:
Quote:
Quote:
>-----------------------------------------------------------------------
>FAQ Topic - How do I open a new window with javascript?
>-----------------------------------------------------------------------
<snip>
Quote:
Perhaps it would be worth adding to that code a minimal statement to write
into a specific element
>
wRef.document.getElementById("X").innerHTML = "Z" // to <p ID=X>
I would think that, by nature, a FAQ entry should address only one
topic. It is my understanding that opening a window, accessing some
other document and modifying a document structure are three different
matters, identified as such in the current version of the FAQ. Would you
use that very example for all of them? :)
Dr J R Stockton
Guest
 
Posts: n/a
#4: Nov 23 '06

re: FAQ Topic - How do I open a new window with javascript?


In comp.lang.javascript message <4564f72c$0$5965$426a74cc@news.free.fr>,
Thu, 23 Nov 2006 02:17:34, Elegie <elegie@invalid.comwrote:
Quote:
>Dr J R Stockton wrote:
>
Quote:
Quote:
>>-----------------------------------------------------------------------
>>FAQ Topic - How do I open a new window with javascript?
>>-----------------------------------------------------------------------
>
><snip>
>
Quote:
>Perhaps it would be worth adding to that code a minimal statement to write
>into a specific element
> wRef.document.getElementById("X").innerHTML = "Z" // to <p ID=X>
>
>I would think that, by nature, a FAQ entry should address only one
>topic. It is my understanding that opening a window, accessing some
>other document and modifying a document structure are three different
>matters, identified as such in the current version of the FAQ. Would
>you use that very example for all of them? :)

Anyone wanting to open a new *empty* window is very likely to want to
write to it (wRef.document.body.innerHTML=Str does that, for me).

A recent questioner seemed to want to have a new window containing in
part standard text and in part customised text, for which the quoted
code could be used.

In general, where a number of questions are likely to occur together or
in succession, they can often better be answered together. That may
mean that, while the enlarged entry is a replacement for the original
and should inherit its position in the FAQ, it may need a new Subject
line - "How do I open and use a new window with javascript?" maybe.

ISTM that the fiction that every FAQ Section 4 entry necessarily
corresponds exactly to a specific question once asked should be
abandoned - "Opening and using a new window with javascript?". Instead,
the quasi-questions should be adapted to fit the most useful answers.

However, if Section 4 elements, such as 4.42, were deemed subdivisible
into 4.42.1, 4.42.2, ... then different subdivisions might well be used.
Several existing sub sections of could then be grouped within the
concept of "window-handling".

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm- also batprogs.htm.
Elegie
Guest
 
Posts: n/a
#5: Nov 24 '06

re: FAQ Topic - How do I open a new window with javascript?


Dr J R Stockton wrote:
Quote:
Anyone wanting to open a new *empty* window is very likely to want to
write to it (wRef.document.body.innerHTML=Str does that, for me).
Not "likely" in the case you offer, but "certain", as an empty window is
of strictly no use. However one would never use
wRef.document.body.innerHTML to write to an *empty* window! Rather, one
would employ the "javascript:" pseudo-protocol, or the simple
document.open(), document.write() and document.close() statements.
Quote:
In general, where a number of questions are likely to occur together or
in succession, they can often better be answered together.
Agreed.
Quote:
That may
mean that, while the enlarged entry is a replacement for the original
and should inherit its position in the FAQ, it may need a new Subject
line - "How do I open and use a new window with javascript?" maybe.
I don't know. The current entry, providing an excellent link, already
covers the difficult task of correctly opening a window. However, I fail
to see how the "use" that you propose differs from basic DOM
manipulations (unless you would like to later emphasize how the "opener"
property works, or how to move, raise, lower, resize... an existing
window - in which case you might have a point).
Quote:
ISTM that the fiction that every FAQ Section 4 entry necessarily
corresponds exactly to a specific question once asked should be
abandoned - "Opening and using a new window with javascript?". Instead,
the quasi-questions should be adapted to fit the most useful answers.
It seems to me that this is already what the FAQ is doing, by splitting
entries into very small units, and providing links to external resources
(or FAQ notes if no satisfying resource is available) for further
analysis by the reader.

However, I suppose that only empirical analysis could stress the
validity of the current model, though it might simply demonstrate that
some FAQ entries are now outdated, and that some new ones might just
need to be added (along with appropriate links).


Kind regards,
Elegie.
Closed Thread