Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #19571 > unrolled thread
| Started by | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| First post | 2013-05-02 18:08 +1000 |
| Last post | 2013-05-02 21:20 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to comp.lang.javascript
iframe scrolled by how much Andrew Poulos <ap_prog@hotmail.com> - 2013-05-02 18:08 +1000
Re: iframe scrolled by how much "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-02 13:58 +0200
Re: iframe scrolled by how much Andrew Poulos <ap_prog@hotmail.com> - 2013-05-02 22:39 +1000
Re: iframe scrolled by how much "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-02 14:48 +0200
Re: iframe scrolled by how much Andrew Poulos <ap_prog@hotmail.com> - 2013-05-03 08:32 +1000
Re: iframe scrolled by how much "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-03 08:38 +0200
Re: iframe scrolled by how much Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-02 21:20 +0200
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2013-05-02 18:08 +1000 |
| Subject | iframe scrolled by how much |
| Message-ID | <HqidnRXFEeGYgh_MnZ2dnUVZ_gSdnZ2d@westnet.com.au> |
If I get a reference to an iframe using
var myfrm = document.getElementsByTagName("iframe")[0];
how do I get the scrollLeft and Top of the iframe?
Andrew Poulos
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-05-02 13:58 +0200 |
| Message-ID | <XnsA1B48E1A8BC9Ceejj99@194.109.133.133> |
| In reply to | #19571 |
Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
> If I get a reference to an iframe using
> var myfrm = document.getElementsByTagName("iframe")[0];
> how do I get the scrollLeft and Top of the iframe?
function showScrollTop() {
var frm = document.getElementsByTagName("iframe")[0];
frm = (frm.contentWindow || frm.contentDocument);
frm = (frm.document || frm);
alert('Top: ' + frm.body.scrollTop+'px');
alert('Left: ' + frm.body.scrollLeft+'px');
};
Works only in same domain, so also not local [without localhost ?].
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2013-05-02 22:39 +1000 |
| Message-ID | <7b2dnVaGSOsFwx_MnZ2dnUVZ_vKdnZ2d@westnet.com.au> |
| In reply to | #19576 |
On 2/05/2013 9:58 PM, Evertjan. wrote:
> Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
>
>> If I get a reference to an iframe using
>> var myfrm = document.getElementsByTagName("iframe")[0];
>> how do I get the scrollLeft and Top of the iframe?
>
> function showScrollTop() {
> var frm = document.getElementsByTagName("iframe")[0];
> frm = (frm.contentWindow || frm.contentDocument);
> frm = (frm.document || frm);
>
> alert('Top: ' + frm.body.scrollTop+'px');
> alert('Left: ' + frm.body.scrollLeft+'px');
> };
>
> Works only in same domain, so also not local [without localhost ?].
To get IE9 to return anything but 0 I had to use documentElement:
window.alert('Top: ' + frm.documentElement.scrollTop + 'px');
Does it mean that the possible permutations are
document.gEBTN("iframe")[0].contentWindow.document.body
document.gEBTN("iframe")[0].contentWindow.document.documentElement
document.gEBTN("iframe")[0].contentDocument.body
document.gEBTN("iframe")[0].contentDocument.documentElement
?
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-05-02 14:48 +0200 |
| Message-ID | <XnsA1B4969FD1484eejj99@194.109.133.133> |
| In reply to | #19579 |
Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
> On 2/05/2013 9:58 PM, Evertjan. wrote:
>> Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
>>
>>> If I get a reference to an iframe using
>>> var myfrm = document.getElementsByTagName("iframe")[0];
>>> how do I get the scrollLeft and Top of the iframe?
>>
>> function showScrollTop() {
>> var frm = document.getElementsByTagName("iframe")[0];
>> frm = (frm.contentWindow || frm.contentDocument);
>> frm = (frm.document || frm);
/***/
>> alert('Top: ' + frm.body.scrollTop+'px');
>> alert('Left: ' + frm.body.scrollLeft+'px');
>> };
>>
>> Works only in same domain, so also not local [without localhost ?].
>
> To get IE9 to return anything but 0 I had to use documentElement:
> window.alert('Top: ' + frm.documentElement.scrollTop + 'px');
> Does it mean that the possible permutations are
>
> document.gEBTN("iframe")[0].contentWindow.document.body
> document.gEBTN("iframe")[0].contentWindow.document.documentElement
> document.gEBTN("iframe")[0].contentDocument.body
> document.gEBTN("iframe")[0].contentDocument.documentElement
I could test that out, but so could you, methinks.
perhaps you could try to add here /***/:
frm = (frm.documentElement || frm);
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2013-05-03 08:32 +1000 |
| Message-ID | <gu2dne-MrPUMdB_MnZ2dnUVZ_rydnZ2d@westnet.com.au> |
| In reply to | #19580 |
On 2/05/2013 10:48 PM, Evertjan. wrote:
> Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
>
>> On 2/05/2013 9:58 PM, Evertjan. wrote:
>>> Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
>>>
>>>> If I get a reference to an iframe using
>>>> var myfrm = document.getElementsByTagName("iframe")[0];
>>>> how do I get the scrollLeft and Top of the iframe?
>>>
>>> function showScrollTop() {
>>> var frm = document.getElementsByTagName("iframe")[0];
>>> frm = (frm.contentWindow || frm.contentDocument);
>>> frm = (frm.document || frm);
> /***/
>>> alert('Top: ' + frm.body.scrollTop+'px');
>>> alert('Left: ' + frm.body.scrollLeft+'px');
>>> };
>>>
>>> Works only in same domain, so also not local [without localhost ?].
>>
>> To get IE9 to return anything but 0 I had to use documentElement:
>> window.alert('Top: ' + frm.documentElement.scrollTop + 'px');
>
>> Does it mean that the possible permutations are
>>
>> document.gEBTN("iframe")[0].contentWindow.document.body
>> document.gEBTN("iframe")[0].contentWindow.document.documentElement
>> document.gEBTN("iframe")[0].contentDocument.body
>> document.gEBTN("iframe")[0].contentDocument.documentElement
Both these
document.gEBTN("iframe")[0].contentWindow.document.body
document.gEBTN("iframe")[0].contentWindow.document.documentElement
seem to work in their respective browsers.
> I could test that out, but so could you, methinks.
>
> perhaps you could try to add here /***/:
Thanks I'm getting a value consistently now but I'm sure of the approach
I'm using.
> frm = (frm.documentElement || frm);
What I'm doing now is:
var frm = document.getElementsByTagName("iframe")[0];
frm = (frm.contentWindow || frm.contentDocument).document;
window.alert(frm.documentElement.scrollLeft || frm.body.scrollLeft);
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-05-03 08:38 +0200 |
| Message-ID | <XnsA1B557E1D65F2eejj99@194.109.133.133> |
| In reply to | #19603 |
Andrew Poulos wrote on 03 mei 2013 in comp.lang.javascript:
> On 2/05/2013 10:48 PM, Evertjan. wrote:
>> Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
>>
>>> On 2/05/2013 9:58 PM, Evertjan. wrote:
>>>> Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
>>>>
>>>>> If I get a reference to an iframe using
>>>>> var myfrm = document.getElementsByTagName("iframe")[0];
>>>>> how do I get the scrollLeft and Top of the iframe?
>>>>
>>>> function showScrollTop() {
>>>> var frm = document.getElementsByTagName("iframe")[0];
>>>> frm = (frm.contentWindow || frm.contentDocument);
>>>> frm = (frm.document || frm);
>> /***/
>>>> alert('Top: ' + frm.body.scrollTop+'px');
>>>> alert('Left: ' + frm.body.scrollLeft+'px');
>>>> };
>>>>
>>>> Works only in same domain, so also not local [without localhost ?].
>>>
>>> To get IE9 to return anything but 0 I had to use documentElement:
>>> window.alert('Top: ' + frm.documentElement.scrollTop + 'px');
>>
>>> Does it mean that the possible permutations are
>>>
>>> document.gEBTN("iframe")[0].contentWindow.document.body
>>> document.gEBTN("iframe")[0].contentWindow.document.documentElement
>>> document.gEBTN("iframe")[0].contentDocument.body
>>> document.gEBTN("iframe")[0].contentDocument.documentElement
>
> Both these
> document.gEBTN("iframe")[0].contentWindow.document.body
> document.gEBTN("iframe")[0].contentWindow.document.documentElement
> seem to work in their respective browsers.
>
>> I could test that out, but so could you, methinks.
>>
>> perhaps you could try to add here /***/:
>
> Thanks I'm getting a value consistently now but I'm sure of the approach
> I'm using.
>
>> frm = (frm.documentElement || frm);
>
> What I'm doing now is:
>
> var frm = document.getElementsByTagName("iframe")[0];
> frm = (frm.contentWindow || frm.contentDocument).document;
>
> window.alert(frm.documentElement.scrollLeft || frm.body.scrollLeft);
See:
> I could test that out, but so could you, methinks.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-05-02 21:20 +0200 |
| Message-ID | <2454054.W8v1AkpiNS@PointedEars.de> |
| In reply to | #19579 |
Andrew Poulos wrote:
> On 2/05/2013 9:58 PM, Evertjan. wrote:
>> Andrew Poulos wrote on 02 mei 2013 in comp.lang.javascript:
>>> If I get a reference to an iframe using
>>> var myfrm = document.getElementsByTagName("iframe")[0];
>>> how do I get the scrollLeft and Top of the iframe?
>>
>> function showScrollTop() {
>> var frm = document.getElementsByTagName("iframe")[0];
>> frm = (frm.contentWindow || frm.contentDocument);
>> frm = (frm.document || frm);
>>
>> alert('Top: ' + frm.body.scrollTop+'px');
>> alert('Left: ' + frm.body.scrollLeft+'px');
>> };
>>
>> Works only in same domain, so also not local [without localhost ?].
>
> To get IE9 to return anything but 0 I had to use documentElement:
> window.alert('Top: ' + frm.documentElement.scrollTop + 'px');
>
> Does it mean that the possible permutations are
>
> document.gEBTN("iframe")[0].contentWindow.document.body
> document.gEBTN("iframe")[0].contentWindow.document.documentElement
> document.gEBTN("iframe")[0].contentDocument.body
> document.gEBTN("iframe")[0].contentDocument.documentElement
>
> ?
Yes, if you cannot control the content of the iframe and so, which rendering
mode will be used. However, it is easier to access the iframe context's
WindowProxy object by name or index, using the “frames” collection:
window.frames["myiframe"].document.body
window.frames["myiframe"].document.documentElement
window.frames[0].document.body
window.frames[0].document.documentElement
This referencing, which originates from “DOM Level 0”, is specified in HTML5
(CR):
<http://www.w3.org/TR/2012/CR-html5-20121217/browsers.html#the-window-
object>
(The WindowProxy object appears to be underdefined, but one can see where
this is going.)
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web