Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    Last edited by optimism_; 02-26-2003 at 06:24 PM.
    <?XML version="1.0" standalone="Yes" encoding="utf-8"?>
    <SIGNITURE>
    XML is the future - embrace it
    </SIGNITURE>

  • #2
    New Coder
    Join Date
    Jan 2003
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •