From: Andrew Poulos on
I'm opening a new window which displays a 3rd party elearning course.
The user may close the course at any time. Whenever the course is closed
I need to trigger some code in window.opener. I thought of:

1. creating a frameset and putting the course in it but that means that
the course has to call window.top.close() otherwise my unload code in
the frameset won't run because:
the course might "wrongly" call window.close().)
the course might have frame busting code

2. appending some of my own code to the course but I don't know what the
course developer may do to the page. They might go to a new page.

3. using setinterval and polling for an open course window.

Is 3 the best way to go.

From: me on

"Andrew Poulos" <ap_prog(a)hotmail.com> wrote in message
news:8MmdnfFOIrEnAcrRnZ2dnUVZ_g-dnZ2d(a)westnet.com.au...
> I'm opening a new window which displays a 3rd party elearning course. The
> user may close the course at any time. Whenever the course is closed I
> need to trigger some code in window.opener. I thought of:
>
> 1. creating a frameset and putting the course in it but that means that
> the course has to call window.top.close() otherwise my unload code in the
> frameset won't run because:
> the course might "wrongly" call window.close().)
> the course might have frame busting code
>
> 2. appending some of my own code to the course but I don't know what the
> course developer may do to the page. They might go to a new page.
>
> 3. using setinterval and polling for an open course window.
>
> Is 3 the best way to go.
>
>

Have you tried attaching an onbeforeunload event to the new window from
within the opener window ? You may run into problems with security
settings if the 3rd party content is on another server, though.

Marc.


From: Andrew Poulos on
On 3/08/2010 2:53 PM, me wrote:
> "Andrew Poulos"<ap_prog(a)hotmail.com> wrote in message
> news:8MmdnfFOIrEnAcrRnZ2dnUVZ_g-dnZ2d(a)westnet.com.au...
>> I'm opening a new window which displays a 3rd party elearning course. The
>> user may close the course at any time. Whenever the course is closed I
>> need to trigger some code in window.opener. I thought of:
>>
>> 1. creating a frameset and putting the course in it but that means that
>> the course has to call window.top.close() otherwise my unload code in the
>> frameset won't run because:
>> the course might "wrongly" call window.close().)
>> the course might have frame busting code
>>
>> 2. appending some of my own code to the course but I don't know what the
>> course developer may do to the page. They might go to a new page.
>>
>> 3. using setinterval and polling for an open course window.
>>
>> Is 3 the best way to go.
>>
>>
>
> Have you tried attaching an onbeforeunload event to the new window from
> within the opener window ? You may run into problems with security
> settings if the 3rd party content is on another server, though.

Hmm, its unlikely that the course will be on a different server though:

- in elearning courses using onbeforeunload is not an uncommon way to
update a user's course status before they close the course so it might
be already assigned (but I could use addeventlistener.)

- if the course changes the URL of its window doesn't that kill any
events attached to the window? So do I need to check whether the window
has indeed been closed and, if it hasn't, attach onbeforeonload again???

Andrew Poulos


From: RobG on
On Aug 3, 2:53 pm, "me" <m...(a)example.com> wrote:
> "Andrew Poulos" <ap_p...(a)hotmail.com> wrote in message
> news:8MmdnfFOIrEnAcrRnZ2dnUVZ_g-dnZ2d(a)westnet.com.au...
>
> > I'm opening a new window which displays a 3rd party elearning course. The
> > user may close the course at any time. Whenever the course is closed I
> > need to trigger some code in window.opener.

You could offer a close button and hope they use it. What if they
close the opener while the child is still around?

You could also put a focus listener on the opener. If it gets focus,
check for the opened window. Note that some browsers will allow a user
to prevent script from moving, resizing or promoting windows.

[...]

> > 3. using setinterval and polling for an open course window.

Ugly. :-( Use focus().


> > Is 3 the best way to go.
>
> Have you tried attaching an onbeforeunload event

That (Microsoft proprietary) event will fire on events other than
window.close:

<URL: http://msdn.microsoft.com/en-us/library/ms536907%28v=vs.85%29.aspx
>


--
Rob
From: Jeff North on
On Tue, 03 Aug 2010 14:35:56 +1000, in comp.lang.javascript Andrew
Poulos <ap_prog(a)hotmail.com>
<8MmdnfFOIrEnAcrRnZ2dnUVZ_g-dnZ2d(a)westnet.com.au> wrote:

>| I'm opening a new window which displays a 3rd party elearning course.
>| The user may close the course at any time. Whenever the course is closed
>| I need to trigger some code in window.opener. I thought of:
>|
>| 1. creating a frameset and putting the course in it but that means that
>| the course has to call window.top.close() otherwise my unload code in
>| the frameset won't run because:
>| the course might "wrongly" call window.close().)
>| the course might have frame busting code
>|
>| 2. appending some of my own code to the course but I don't know what the
>| course developer may do to the page. They might go to a new page.
>|
>| 3. using setinterval and polling for an open course window.
>|
>| Is 3 the best way to go.

Have you thought of using lightbox/greybox for the popup window?