Controlling specific popup window

M

Math

Hi,
I have a main HTML page who opens diferrent popup windows, each of them with
a specific ID.

Now my needs are to refresh the content of only one of them at onClick event
on main page.

The function used to open popup is:

function showImagePopUp(pURL, idFoto){
var id = 'popup_'+idFoto;
var popW = 830, popH = 700;
var winl = (screen.width-popW)/2;
var wint = (screen.height-popH)/2;
popup_win = window.open(pURL, id,
'status=no,resizable=1,scrollbars=1,width=' + popW + ',height=' + popH +
',top=' + wint + ',left=' + winl);
}

My question is: how can i get the correct window object to apply the reload
method?

Greetings and thanks for any suggestion.


-f
 
T

Thomas 'PointedEars' Lahn

Math said:
I have a main HTML page who opens diferrent popup windows, each of them with
a specific ID.

Windows do not have an ID, they have a name.
Now my needs are to refresh the content of only one of them at onClick event
on main page.
[...]
My question is: how can i get the correct window object to apply the reload
method?

You don't really need Location::reload(), usually proper cache control
headers would suffice: Just pass the same name you used before with
window.open() and a different or the same URI. However, window.open()
will then return the object reference which you can use to call any method
of the respective Window object or of the objects its properties refer to.

You can also keep the retrieved object reference globally available;
however, you would then need to test whether the reference is still valid
before using it as the reference base for a method call.

http://jibbering.com/faq/#FAQ4_10
http://jibbering.com/faq/#FAQ4_42

<FAQENTRY>
http://developer.mozilla.org/en/docs/DOM:window.open
http://developer.mozilla.org/en/docs/DOM:window.open#FAQ
</FAQENTRY>


PointedEars
 
D

Doug Gunnoe

Hi,
I have a main HTML page who opens diferrent popup windows, each of them with
a specific ID.

Now my needs are to refresh the content of only one of them at onClick event
on main page.

The function used to open popup is:

function showImagePopUp(pURL, idFoto){
 var id = 'popup_'+idFoto;
 var popW = 830, popH = 700;
 var winl = (screen.width-popW)/2;
 var wint = (screen.height-popH)/2;
 popup_win = window.open(pURL, id,
'status=no,resizable=1,scrollbars=1,width=' + popW + ',height=' + popH +
',top=' + wint + ',left=' + winl);

}

My question is: how can i get the correct window object to apply the reload
method?

Greetings and thanks for any suggestion.

-f

When you do popup_win = window.open(...), you can control that popup
window with popup_win.

But I guess you are calling this function several times and each time
it assigns popup_win to a new window.

There is probably a better way, but here is the first thing that comes
to mind. Change popup_win to an array.

popup_win = [];

Then every time you open a window, do

popup_win = window.open(blah, blah...);

Then when you want to reload the specific window,

popup_win[index].location.href = popup_win[index].location.href.

or use the reload method.

no promises that it will actually refresh the page properly.

I was thinking all the child windows of a document would be
automatically stored in an array and could be iterated through in the
same way one could navigate elements in the DOM, but apparently not.
Either that, or I just can't find that info.
 
T

Thomas 'PointedEars' Lahn

Doug said:
I have a main HTML page who opens diferrent popup windows, each of them with
a specific ID.

Now my needs are to refresh the content of only one of them at onClick event
on main page.

The function used to open popup is:

function showImagePopUp(pURL, idFoto){
var id = 'popup_'+idFoto;
[...]
var wint = (screen.height-popH)/2;
popup_win = window.open(pURL, id,
'status=no,resizable=1,scrollbars=1,width=' + popW + ',height=' + popH +
',top=' + wint + ',left=' + winl);
}

My question is: how can i get the correct window object to apply the reload
method?
[...]

[...]
There is probably a better way, but here is the first thing that comes
to mind. Change popup_win to an array.

popup_win = [];

Then every time you open a window, do

popup_win = window.open(blah, blah...);


`popup_win' could also be a reference to an Object object, with the window
names as property names. However, using an augmented Array object it would
be possible to implement a collection, so that the Windows can be referred
to by numeric and alphanumeric property name, and the `length' property
would be updated automatically.

See also http://pointedears.de/scripts/collection.js
[...]
I was thinking all the child windows of a document would be
automatically stored in an array and could be iterated through in the
same way one could navigate elements in the DOM, but apparently not.
Either that, or I just can't find that info.

You thought wrong.


PointedEars
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top