Check for existing array from another page

D

Dave

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
 
K

Klaus Johannes Rusch

Dave said:
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?

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).
 
D

Dave

Klaus Johannes Rusch said:
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).

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top