New Popup Window from an existing Popup Window

R

Raffi

I need to do the following:

From the main page I click a link button and open a javascript popup
window. So far so good. Now when i try to open a new popup window from
a button link in the first popup window, it redirects the existing
popup window to the new URL. I need to have it open a new popup window
(of a different size) to display the new page. How can I do this?

Thanks,

Raffi
 
L

lallous

Hello

You need to give a different window name to each popup, do this like:

// global variable
var x = 0;

window.open('theUrl.htm', 'window'+(x++), 'options here...');
 
T

Thomas 'PointedEars' Lahn

lallous said:
You need to give a different window name to each popup, do this like:

// global variable
var x = 0;

window.open('theUrl.htm', 'window'+(x++), 'options here...');

Globals are evil[tm] and in most cases not required. Besides, the global
variable is attached to the current window. If I open the popup that
contains the above code with

window.open(..., 'window1', ...')

the above statement of yours will re-use that popup anyway.
A better approach:

window.open('...', 'window' + new Date().getTime(), '...');

Since the return value of Date.prototype.getTime() changes every
millisecond, it is unlikely that an existing window will be reused.
If the return value of that method "jumps" forth/back because of
switching from/to daylight saving time, it is unlikely that a window
will be reused either because that would require thousands of named
windows to be open.
[Top post]

<http://www.jibbering.com/faq/faq_notes/pots1.html#ps1Post>


PointedEars
 
R

Raffi

Thomas 'PointedEars' Lahn said:
lallous said:
You need to give a different window name to each popup, do this like:

// global variable
var x = 0;

window.open('theUrl.htm', 'window'+(x++), 'options here...');

Globals are evil[tm] and in most cases not required. Besides, the global
variable is attached to the current window. If I open the popup that
contains the above code with

window.open(..., 'window1', ...')

the above statement of yours will re-use that popup anyway.
A better approach:

window.open('...', 'window' + new Date().getTime(), '...');

Since the return value of Date.prototype.getTime() changes every
millisecond, it is unlikely that an existing window will be reused.
If the return value of that method "jumps" forth/back because of
switching from/to daylight saving time, it is unlikely that a window
will be reused either because that would require thousands of named
windows to be open.
[Top post]

<http://www.jibbering.com/faq/faq_notes/pots1.html#ps1Post>


PointedEars

Thanks for the suggestions. I figured it out. I'm opening the
different windows without using too many globals, other than a couple
of variables for the popup window position.

Raffi
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Wed, 11 Aug
2004 19:31:02, seen in Thomas 'PointedEars'
Lahn said:
A better approach:

window.open('...', 'window' + new Date().getTime(), '...');

Since the return value of Date.prototype.getTime() changes every
millisecond, it is unlikely that an existing window will be reused.
If the return value of that method "jumps" forth/back because of
switching from/to daylight saving time, it is unlikely that a window
will be reused either because that would require thousands of named
windows to be open.


In the words, perhaps imperfectly quoted, of WSC - "Who is Mr Round, and
what is the basis of his objection?".


The return value of Date.prototype.getTime() is on my system zero; it
does not change.

The time resolution of a javascript date object is indeed a millisecond;
but that is not the same as the resolution of new Date() - the latter
is 10 ms in some systems, and 55 ms in some others. There may well be
systems in which its resolution is 1 ms; but an Internet author can rely
on nothing better than 55 ms (worse may be possible, of course).

The stored value represents C/UNIX time_t in milliseconds - that is
measured from 1970-01-01 00:00:00 GMT (leap seconds are ignored). It is
that stored value which is returned by getTime and valueOf. Summer Time
(Sommerzeit) is utterly irrelevant.

If the value did jump back in autumn, duplication would be
possible if a single window were opened in the hour before the
change, and a second were attempted exactly one hour later, at
the identical civil time. Thousands would not be required.

If you had made full & proper use of the newsgroup FAQ, you would have
understood these things.
 

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,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top