From: Andrew Poulos on
On 3/08/2010 4:40 PM, RobG wrote:
> 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?

If the opener is closed the course loses the connection to the
management system. Users generally know not to close the opener (in this
case).

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

That sounds like it might work. Thanks for the idea.

> [...]
>
>>> 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

Dang, what about adding an invisible iframe with an unload event?

Andrew Poulos

From: Andrew Poulos on
On 3/08/2010 6:54 PM, Jeff North wrote:
> 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?

I have no control of nor can I even know much about the course window.
Maybe its a frameset. Maybe the course developer dynamically draws the
page each time the user clicks Next. Maybe its just one PDF. Maybe its a
full screen Flash file...

Andrew Poulos
From: Jeff North on
On Tue, 03 Aug 2010 19:30:40 +1000, in comp.lang.javascript Andrew
Poulos <ap_prog(a)hotmail.com>
<LJCdnS0wOuhdfMrRnZ2dnUVZ_t6dnZ2d(a)westnet.com.au> wrote:

>| On 3/08/2010 6:54 PM, Jeff North wrote:
>| > 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?
>|
>| I have no control of nor can I even know much about the course window.
>| Maybe its a frameset. Maybe the course developer dynamically draws the
>| page each time the user clicks Next. Maybe its just one PDF. Maybe its a
>| full screen Flash file...

Read up on it: http://orangoo.com/labs/GreyBox/
Try the on-page demo.
From: me on
"Andrew Poulos" <ap_prog(a)hotmail.com> wrote in message
news:ArSdnTpuAc1VNcrRnZ2dnUVZ_g2dnZ2d(a)westnet.com.au...
>> 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.
>
> - 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???

As someone else already pointed out, onbeforeunload was a bad
suggestion. The focus idea is probably the way to go.

Marc.


From: Thomas 'PointedEars' Lahn on
Andrew Poulos 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.

No?


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann