Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13876
| Message-ID | <1401679.AFRqVoOGUt@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2012-05-10 19:26 +0200 |
| 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 |
Followups directed to: comp.lang.javascript
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
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