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

F

FAQ server

-----------------------------------------------------------------------
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.
 
D

Dr J R Stockton

In comp.lang.javascript message
-----------------------------------------------------------------------
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>
 
E

Elegie


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? :)
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>,

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".
 
E

Elegie

Dr said:
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.
In general, where a number of questions are likely to occur together or
in succession, they can often better be answered together.
Agreed.

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).
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top