Check for existing array from another page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    Check for existing array from another page

    Can I determine if an array of image links is already in memory
    without using cookies or a hidden frameset? Scenario: visitor starts
    with Home page, images (links) for navigation pre-load no problem.
    Visitor follows search engine link and does not land on Home, thus no
    links. But if I put the same code on every page to allow for that,
    won't the images re-load every time those pages are loaded? If so,
    there's be no point in pre-loading.

    My approach up to now: I tried to set a variable value at the end of
    the pre-load script, and test for it at the begining of the same
    script on each page. Thus, no matter where they land, the pre-load
    script runs if the value does not exist, and doesn't run if it exists.
    Thus on every page the script would be the same, allowing me to use it
    as a template. But I cannot figure out how to discover the existence
    of the variable value when loading other pages. Using the alert
    function tells me it does not exist. Any suggestions (remember, no
    framesets or cookies, please)?

    One thing that just occurred to me: what if I called the same external
    script from each page? Would the variable value be accessible when
    navigating from page to page or would it be reset anyway?
    Thanks for any help.
    Dave
  • Klaus Johannes Rusch

    #2
    Re: Check for existing array from another page

    Dave wrote:
    [color=blue]
    > Can I determine if an array of image links is already in memory
    > without using cookies or a hidden frameset? Scenario: visitor starts
    > with Home page, images (links) for navigation pre-load no problem.
    > Visitor follows search engine link and does not land on Home, thus no
    > links. But if I put the same code on every page to allow for that,
    > won't the images re-load every time those pages are loaded? If so,
    > there's be no point in pre-loading.
    >
    > ...
    > One thing that just occurred to me: what if I called the same external
    > script from each page? Would the variable value be accessible when
    > navigating from page to page or would it be reset anyway?[/color]

    You cannot share variables between different pages, if I understand the
    functionality of your code correctly, this preloads images which are used
    in the navigation. The best solution is to include the Javascript code for
    preloading these images on every page -- on the first page the images will
    get loaded from the server, on subsequent pages they preload will use the
    cached images (depending on cache settings, of course).

    --
    Klaus Johannes Rusch
    KlausRusch@atme dia.net



    Comment

    • Dave

      #3
      Re: Check for existing array from another page

      Klaus Johannes Rusch <KlausRusch@atm edia.net> wrote in message news:<3F24EDB6. 92B834D4@atmedi a.net>...[color=blue]
      > Dave wrote:
      >[color=green]
      > > Can I determine if an array of image links is already in memory
      > > without using cookies or a hidden frameset? Scenario: visitor starts
      > > with Home page, images (links) for navigation pre-load no problem.
      > > Visitor follows search engine link and does not land on Home, thus no
      > > links. But if I put the same code on every page to allow for that,
      > > won't the images re-load every time those pages are loaded? If so,
      > > there's be no point in pre-loading.
      > >
      > > ...
      > > One thing that just occurred to me: what if I called the same external
      > > script from each page? Would the variable value be accessible when
      > > navigating from page to page or would it be reset anyway?[/color]
      >
      > You cannot share variables between different pages, if I understand the
      > functionality of your code correctly, this preloads images which are used
      > in the navigation. The best solution is to include the Javascript code for
      > preloading these images on every page -- on the first page the images will
      > get loaded from the server, on subsequent pages they preload will use the
      > cached images (depending on cache settings, of course).[/color]

      Got hold of a 4th edition copy of Goodman's Javascript Bible before
      reading your reply. After an hour or so, I realized global variables
      don't have the same connotation in JS as they do in VBA. It seems a
      solution (other than your reasonably acceptable one) is to use the
      escape function to create an appendage to the new document URL when
      loading the next page, and look for the appendage when a page loads.
      If it exists, bypass the code. So I tried it. Had it working, but now
      I get an error when the function to swap images runs. Seems my array
      variable is "undefined" . I checked spelling and caps and for the life
      of me, I can't see why.

      Given that there are four possible settings for browser cache(and I'd
      suspect "every visit to page" is default) I lean towards the book
      solution at the moment since cache settings are a hit and miss
      proposition. Now, if I can only figure out why the error. BTW, it's
      probably apparent I'm no JS guru, so if anyone cares to check my
      script to solve my error message, I'd be happy to post it.
      Thanks.

      Comment

      Working...