On May 10, 2:16 am, Scott Johnson wrote:
> I am working with opencart which is templated.
Saying that isn't directly useful as you are probably asking people to
look up "opencart" (assuming that there is only one), which asking for
more than you are likely to get (if its relevant you should provide
the reference), and you have not explained what "templated" means in
this context, or what implications that may have in this context.
> On the foot template file there is a music script (jplayer)
> located on a separate file 'music.html' loaded into a iframe
> on the footer,
That sounds slightly mad, design wise (referring to the iframe use,
playing music at a web site visitor is antisocial but does serve to
reflect informatively on worth of the web site's owner).
> which is
> global across all pages.
>
> The client would only like the jplayer to autoplay on the home page
Because generating a bad first impression is so important?
> so I
> need a way to determine when the home page is called so I can
> play or pause the player in the jplayer script located on
>'music.html'.
So why not put the code that plays the music in the home page mark-up
and not in the footer mark-up where it will serve no purpose most of
the time?
> 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.
No, you would want the URL of the parent page that contains the IFRAME
(i.e. - parent.location.href -).
> 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.
So you can place scripts on that page, and so can run the music player
from there?
> Is this even possible?
Yes, but if you don't understand that each frame will have its own
global environment (so one for the main page and a separate one for
each frame/iframe it contains (and possibly so on recursively) then
you will have as much trouble accessing a global variable defined in
the parent page as you have accessing the - location - object of the
parent page.
> Global variables accessible across scripts.
Yes, but that is the wrong question in context.
> or
> Do I even make sense? :)
I tend to think that there is a minimal level of technical
understanding that should be achieved before it is practical to make
informed design decisions. It is hard to see not having an
understanding of the (navigation of the) nested frame structure that
browsers provide as qualifying.
Richard.