Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19600

Re: iframe scrolled by how much

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!feed.cnntp.org!news.cnntp.org!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <2454054.W8v1AkpiNS@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <usenet@PointedEars.de>
Organization PointedEars Software (PES)
Date Thu, 02 May 2013 21:20:53 +0200
User-Agent KNode/4.8.5
Content-Transfer-Encoding 8Bit
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: iframe scrolled by how much
Newsgroups comp.lang.javascript
References <HqidnRXFEeGYgh_MnZ2dnUVZ_gSdnZ2d@westnet.com.au> <XnsA1B48E1A8BC9Ceejj99@194.109.133.133> <7b2dnVaGSOsFwx_MnZ2dnUVZ_vKdnZ2d@westnet.com.au>
MIME-Version 1.0
Lines 55
NNTP-Posting-Date 02 May 2013 21:20:54 CEST
NNTP-Posting-Host 0743284d.newsspool3.arcor-online.net
X-Trace DXC=@Q1RA7H;NnRcHPTNZh_e7QMcF=Q^Z^V3X4Fo<]lROoRQ8kF<OcfhCO[e1h`^Sj[7o^DZm8W4\YJN\b@mF9jNikdUIQbgJMhLo0W4\fJiZgS0X^
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:19600

Show key headers only | View raw


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.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

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

csiph-web