Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-26-2003, 06:02 PM   PM User | #1
optimism_
New Coder

 
Join Date: Jan 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
optimism_ is an unknown quantity at this point
Preloading Dynamic Images

Now this is a weird problem indeed. I have what could be 4
separate technologies to make a menu bar for my website. The
page includes both html and php. The php exectutes a perl script
which loads the trees blah blah blah and returns some
javascript/image code. The images point to another php page
which dynamically loads the name of the link over 3 basic images,
the normal/hover/active images. The javascript "preloads" the
images and then swaps them over using the
onMouseOver/onMouseOut events.

The problem. Despite the fact the images are preloaded and
stored into image objects, the dynamic-image php
script "navbar.php" is called whenever the images are swapped.
Obviously this is hopless cos theres a massive delay, and the
load on the server is immense.

Here is the preloading function, practically lifted from the code
generated by m$ frontpage.
Code:
<script>
function preload(source) 
{
	var a=new Image();
	a.src=source;
	return a; 
}
</script>
The following is then an extract from the perl script which writed
the image/links
Code:
print <<END;
<script>
var $state$x = preload("http://$ENV{HTTP_HOST}/navbar.php?text=$disp{$tree[$x]}&state=$state");
var Hover$x = preload("http://$ENV{HTTP_HOST}/navbar.php?text=$disp{$tree[$x]}&state=Hover");
</script>
END
print "<a href=\"", $root, $def{$tree[$x]}, "\" 
onMouseOver=\"document['img$x'].src=Hover$x.src\" 
onMouseOut=\"document['img$x'].src=$state$x.src\"><img 
name=\"img$x\" src=\"http://$ENV{HTTP_HOST}/navbar.php?
text=$disp{$tree[$x]}&state=$state\" border=\"0\" /></a>\n";
I have proven the image swapping does not use cached images
because i renamed the navbar.php file and the image changed to
the icon for "cannot find image". Hope someone out there can
help. It really is not practical to have the php generate a new
image each time someone passes a mouse over the link

thx in advance
__________________
<?XML version="1.0" standalone="Yes" encoding="utf-8"?>
<SIGNITURE>
XML is the future - embrace it
</SIGNITURE>

Last edited by optimism_; 02-26-2003 at 06:24 PM..
optimism_ is offline   Reply With Quote
Old 02-27-2003, 11:23 PM   PM User | #2
optimism_
New Coder

 
Join Date: Jan 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
optimism_ is an unknown quantity at this point
C'mon, you ppl gotta have an answer to this problem by now!!!
__________________
<?XML version="1.0" standalone="Yes" encoding="utf-8"?>
<SIGNITURE>
XML is the future - embrace it
</SIGNITURE>
optimism_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:34 PM.


Advertisement
Log in to turn off these ads.