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


Groups > comp.lang.javascript > #13876

Re: Variable scope between <script>

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin.stu.neva.ru!news.tu-darmstadt.de!news.belwue.de!rz.uni-karlsruhe.de!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <1401679.AFRqVoOGUt@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Thu, 10 May 2012 19:26:50 +0200
User-Agent KNode/4.4.11
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: Variable scope between <script>
Newsgroups comp.lang.javascript
References <jof4tq$asa$1@dont-email.me> <jog879$arn$1@news.albasani.net>
Followup-To comp.lang.javascript
MIME-Version 1.0
Lines 52
NNTP-Posting-Date 10 May 2012 19:26:52 CEST
NNTP-Posting-Host d2b210f3.newsspool1.arcor-online.net
X-Trace DXC=HAUmh@j9WS7RLigj];iP=8ic==]BZ:af>4Fo<]lROoR1nkgeX?EC@@0gVYO=MmT0f:DZm8W4\YJN<J`:FmdeL>K0U@3`]Ai;Bf2I3[Lmc:B[T5
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:13876

Followups directed to: comp.lang.javascript

Show key headers only | View raw


Andreas Bergmaier wrote:

> Scott Johnson schrieb:
>> I tried to call window.location.href ? .pathname which sends back the
>> original name of the file the script is located '/~domain/music.html' as
>> expected but not helpful.
>>
>> What I was thinking was place the window.location.pathname on the 'home'
>> page set a global variable which can be read by the script on music.html.
>>
>> Is this even possible?
>> Global variables accessible across scripts.
> 
> You can access the global object of the parent window with "parent",
> even the global object of the top window with "top" for deeply nested
> frames.

`parent' and `top' are actually properties of Window objects.

<http://docs.oracle.com/cd/E19957-01/816-6408-10/window.htm>

> Precondition is that both pages are located in the same domain
> for security reasons, which will be no problem in your case.

Without further measures, it must be the same protocol, the same domain, and 
the same port number (Same Origin Policy).  It may also be possible if both 
protocol and port number match and the URIs used to access both resources 
are in the same subdomain (simplest case: same second-level domain).  I am 
not sure if assigning to `document.domain' still works in recent browsers.  
I have not tried again; no use-case.  But it would certainly be tested as 
part of a DOM Support Matrix.

<https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript>
<http://docs.oracle.com/cd/E19957-01/816-6408-10/document.htm#1193628>

> So you may check parent.location.href, […]

The `href' property of Location objects was tainted, the `location' property 
of Window objects was not.  So, slightly greater efficiency aside, it 
appears to be safer and more flexible to use the `location' property 
instead.  It appears to have a getter which returns the value of the `href' 
property of the referred Location object.

<http://docs.oracle.com/cd/E19957-01/816-6408-10/window.htm#1202507>


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

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


Thread

Variable scope between <script> Scott Johnson <noonehome@chalupasworld.com> - 2012-05-09 18:16 -0700
  Re: Variable scope between <script> Andreas Bergmaier <andber93@web.de> - 2012-05-10 13:19 +0200
    Re: Variable scope between <script> Scott Johnson <noonehome@chalupasworld.com> - 2012-05-10 05:16 -0700
    Re: Variable scope between <script> Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-10 19:26 +0200
  Re: Variable scope between <script> Richard Cornford <Richard@litotes.demon.co.uk> - 2012-05-10 04:19 -0700

csiph-web