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


Groups > comp.lang.javascript > #13875

Re: Variable scope between <script>

From Scott Johnson <noonehome@chalupasworld.com>
Newsgroups comp.lang.javascript
Subject Re: Variable scope between <script>
Date 2012-05-10 05:16 -0700
Organization A noiseless patient Spider
Message-ID <jogbik$1n0$1@dont-email.me> (permalink)
References <jof4tq$asa$1@dont-email.me> <jog879$arn$1@news.albasani.net>

Show all headers | View raw


On 5/10/2012 4:19 AM, 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. Precondition is that both pages are located in the same domain
> for security reasons, which will be no problem in your case.
>
> So you may check parent.location.href, but you can also set up a
> function in the homepage that calls the play() function in the frame by
> accessing the frame's global object.
>
> regards,
> Bergi

Ahhh.

parent & top

That makes sense.  I will give that some experimentation.

Thanks for the reply.  That is very good info to know.

Scotty

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