Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25034 > unrolled thread
| Started by | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| First post | 2014-06-26 10:06 +1000 |
| Last post | 2014-06-27 00:18 +0200 |
| Articles | 7 — 2 participants |
Back to article view | Back to comp.lang.javascript
Closing a lesson in iframe Andrew Poulos <ap_prog@hotmail.com> - 2014-06-26 10:06 +1000
Re: Closing a lesson in iframe Andrew Poulos <ap_prog@hotmail.com> - 2014-06-26 13:52 +1000
Re: Closing a lesson in iframe Andrew Poulos <ap_prog@hotmail.com> - 2014-06-26 14:26 +1000
Re: Closing a lesson in iframe Andrew Poulos <ap_prog@hotmail.com> - 2014-06-26 15:31 +1000
Re: Closing a lesson in iframe Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-26 15:35 +0200
Re: Closing a lesson in iframe Andrew Poulos <ap_prog@hotmail.com> - 2014-06-27 07:30 +1000
Re: Closing a lesson in iframe Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-27 00:18 +0200
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-06-26 10:06 +1000 |
| Subject | Closing a lesson in iframe |
| Message-ID | <sd2dnZqzLrIa-TbOnZ2dnUVZ_tednZ2d@westnet.com.au> |
I have a 3rd party elearning lesson displayed within an iframe. The
lesson contains a 'close' button which calls window.top.close(); - other
lessons might call window.close();
The parent window contains the learning management system (LMS). This
window is not to close when the lesson is closed.
I've tried a number of things and so far the closest I've got is this:
// In the parent page the iframe is 'ifrm'
ifrm.onload = function() {
var oDoc = (ifrm.contentWindow || ifrm.contentDocument);
oDoc.top.close = fCloseFrame;
oDoc.close = fCloseFrame;
};
fCloseFrame = function() {
var f= document.getElementById("cmtLesson");
if (f) document.body.removeChild(f);
};
It seems to "work" on my android phone but on my windows desktop and IE9
closes the parent window.
If I add
function foo() { window.alert('a'); }
to the lesson then from the parent page window.alert(oDoc.foo); IE will
correctly display foo.
How can I intercept the call to close() from the iframe in the parent
with IE and only "close" the iframe itself?
Andrew Poulos
[toc] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-06-26 13:52 +1000 |
| Message-ID | <ReudnWKwTv88BDbOnZ2dnUVZ_tWdnZ2d@westnet.com.au> |
| In reply to | #25034 |
On 26/06/2014 10:06 AM, Andrew Poulos wrote:
> I have a 3rd party elearning lesson displayed within an iframe. The
> lesson contains a 'close' button which calls window.top.close(); - other
> lessons might call window.close();
>
> The parent window contains the learning management system (LMS). This
> window is not to close when the lesson is closed.
>
> I've tried a number of things and so far the closest I've got is this:
>
> // In the parent page the iframe is 'ifrm'
> ifrm.onload = function() {
> var oDoc = (ifrm.contentWindow || ifrm.contentDocument);
> oDoc.top.close = fCloseFrame;
> oDoc.close = fCloseFrame;
> };
>
> fCloseFrame = function() {
> var f= document.getElementById("cmtLesson");
> if (f) document.body.removeChild(f);
> };
>
> It seems to "work" on my android phone but on my windows desktop and IE9
> closes the parent window.
>
> If I add
> function foo() { window.alert('a'); }
> to the lesson then from the parent page window.alert(oDoc.foo); IE will
> correctly display foo.
>
> How can I intercept the call to close() from the iframe in the parent
> with IE and only "close" the iframe itself?
To answer my own question, I replaced the code above with
function close() {
var tmp = document.getElementById("cmtLesson");
if (tmp) document.body.removeChild(tmp);
}
and IE, android... all seem to do what's needed.
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-06-26 14:26 +1000 |
| Message-ID | <icCdnQ9P9tQ5PDbOnZ2dnUVZ_sCdnZ2d@westnet.com.au> |
| In reply to | #25035 |
On 26/06/2014 1:52 PM, Andrew Poulos wrote:
> On 26/06/2014 10:06 AM, Andrew Poulos wrote:
>> I have a 3rd party elearning lesson displayed within an iframe. The
>> lesson contains a 'close' button which calls window.top.close(); - other
>> lessons might call window.close();
>>
>> The parent window contains the learning management system (LMS). This
>> window is not to close when the lesson is closed.
>>
>> I've tried a number of things and so far the closest I've got is this:
>>
>> // In the parent page the iframe is 'ifrm'
>> ifrm.onload = function() {
>> var oDoc = (ifrm.contentWindow || ifrm.contentDocument);
>> oDoc.top.close = fCloseFrame;
>> oDoc.close = fCloseFrame;
>> };
>>
>> fCloseFrame = function() {
>> var f= document.getElementById("cmtLesson");
>> if (f) document.body.removeChild(f);
>> };
>>
>> It seems to "work" on my android phone but on my windows desktop and IE9
>> closes the parent window.
>>
>> If I add
>> function foo() { window.alert('a'); }
>> to the lesson then from the parent page window.alert(oDoc.foo); IE will
>> correctly display foo.
>>
>> How can I intercept the call to close() from the iframe in the parent
>> with IE and only "close" the iframe itself?
>
> To answer my own question, I replaced the code above with
>
> function close() {
> var tmp = document.getElementById("cmtLesson");
> if (tmp) document.body.removeChild(tmp);
> }
>
> and IE, android... all seem to do what's needed.
Dang, it works if the lesson calls window.top.close() but not if it
calls window.close();
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-06-26 15:31 +1000 |
| Message-ID | <lLqdnUSFRdApLTbOnZ2dnUVZ_rGdnZ2d@westnet.com.au> |
| In reply to | #25036 |
On 26/06/2014 2:26 PM, Andrew Poulos wrote:
>> function close() {
>> var tmp = document.getElementById("cmtLesson");
>> if (tmp) document.body.removeChild(tmp);
>> }
>>
>> and IE, android... all seem to do what's needed.
>
> Dang, it works if the lesson calls window.top.close() but not if it
> calls window.close();
Using IE I can't override close() in one window (the iframe) from
another (the iframe's parent).
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-06-26 15:35 +0200 |
| Message-ID | <53ac21b1$0$6608$9b4e6d93@newsspool4.arcor-online.net> |
| In reply to | #25034 |
Andrew Poulos wrote:
> I have a 3rd party elearning lesson displayed within an iframe. The
> lesson contains a 'close' button which calls window.top.close(); - other
> lessons might call window.close();
>
> The parent window contains the learning management system (LMS). This
> window is not to close when the lesson is closed.
>
> I've tried a number of things and so far the closest I've got is this:
>
> // In the parent page the iframe is 'ifrm'
> ifrm.onload = function() {
> var oDoc = (ifrm.contentWindow || ifrm.contentDocument);
> oDoc.top.close = fCloseFrame;
> oDoc.close = fCloseFrame;
> };
>
> fCloseFrame = function() {
> var f= document.getElementById("cmtLesson");
> if (f) document.body.removeChild(f);
> };
>
> It seems to "work" on my android phone but on my windows desktop and IE9
> closes the parent window.
>
> If I add
> function foo() { window.alert('a'); }
> to the lesson then from the parent page window.alert(oDoc.foo); IE will
> correctly display foo.
>
> How can I intercept the call to close() from the iframe in the parent
> with IE and only "close" the iframe itself?
It seems the 3rd party elearning lessons are served from the same site.
If that is so, you may consider to manipulate the close button
directly, instead of trying to catch the window.(top.)close() it calls.
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-06-27 07:30 +1000 |
| Message-ID | <ioudnW5CcrMVDDHOnZ2dnUVZ_sednZ2d@westnet.com.au> |
| In reply to | #25043 |
On 26/06/2014 11:35 PM, Christoph Michael Becker wrote:
> Andrew Poulos wrote:
>
>> I have a 3rd party elearning lesson displayed within an iframe. The
>> lesson contains a 'close' button which calls window.top.close(); - other
>> lessons might call window.close();
>>
>> The parent window contains the learning management system (LMS). This
>> window is not to close when the lesson is closed.
>>
>> I've tried a number of things and so far the closest I've got is this:
>>
>> // In the parent page the iframe is 'ifrm'
>> ifrm.onload = function() {
>> var oDoc = (ifrm.contentWindow || ifrm.contentDocument);
>> oDoc.top.close = fCloseFrame;
>> oDoc.close = fCloseFrame;
>> };
>>
>> fCloseFrame = function() {
>> var f= document.getElementById("cmtLesson");
>> if (f) document.body.removeChild(f);
>> };
>>
>> It seems to "work" on my android phone but on my windows desktop and IE9
>> closes the parent window.
>>
>> If I add
>> function foo() { window.alert('a'); }
>> to the lesson then from the parent page window.alert(oDoc.foo); IE will
>> correctly display foo.
>>
>> How can I intercept the call to close() from the iframe in the parent
>> with IE and only "close" the iframe itself?
>
> It seems the 3rd party elearning lessons are served from the same site.
> If that is so, you may consider to manipulate the close button
> directly, instead of trying to catch the window.(top.)close() it calls.
>
Alas the lessons aren't standard. Some may be a "single page" app, some
multiple, some an embedded Flash piece...
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-06-27 00:18 +0200 |
| Message-ID | <53ac9c2d$0$6606$9b4e6d93@newsspool4.arcor-online.net> |
| In reply to | #25052 |
Andrew Poulos: > On 26/06/2014 11:35 PM, Christoph Michael Becker wrote: > >> It seems the 3rd party elearning lessons are served from the same site. >> If that is so, you may consider to manipulate the close button >> directly, instead of trying to catch the window.(top.)close() it calls. >> > Alas the lessons aren't standard. Some may be a "single page" app, some > multiple, some an embedded Flash piece... Um, then maybe listening to the beforeunload event and preventing its default action might be a viable solution. -- Christoph M. Becker
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web