Re: Simple image swap not working...Why?



Tony scribed:

Lee wrote:
Ed Jay said:

VK scribed:


Ed Jay wrote:

Why doesn't the following swap images?

<head>
<javascript type="text/javascript">
function swapImage() {document.images.image1.src=/images/1stimage.gif;}
function swapBack() {document.images.image1.src=/images/2ndimage.gif;}
</script>
</head><body>

because you did not enclose the URI string in quotes:

document.images.image1.src="/images/1stimage.gif";

Sorry, but I didn't include the quotes. Actual code is as you've shown,
i.e.,

function swapImage() {document.images.image1.src="/images/1stimage.gif";}
function swapBack() {document.images.image1.src="/images/2ndimage.gif";}


You see how you waste resources when you don't copy and paste the
actual code? The pathnames to your images are probably wrong.
Open each image directly in your browser and copy the full URL
into your code.

Actually, the way the paths are defined, it's looking for directory
'images' under the root.

I'd be willing to bet that removing the preceding '/' would help -

No, but adding either the path to root or a single period would.
../images/image.gif

and a
bit of time spent learning the difference between absolute & relative paths

:-)
--
Ed Jay (remove 'M' to respond by email)
.



Relevant Pages

  • Re: How to remove virtual path from root url of dev web server?
    ... Why do you develop in the root of your development server? ... the possibility of having additional applications in your server. ... > even folder where a page ran from to have a images subfolder with the images in there. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Netinstall
    ... I'm trying to install Sarge on a Toshiba Portege R100 laptop. ... machine does not have a CD-ROM or floppy drive built in and I don't have ... images from it, but I can't seem to find the right images to load. ... VFS: Mounted root. ...
    (Debian-User)
  • Re: img tag ../ ./ / ???
    ... Microsoft Online Support ... | the path is start from the IIS website 's root folder. ... | contains an "Images" subfolder, the images in that folder's url should be: ... | |> design mode giving me a pretty close wysiwyg at design time. ...
    (microsoft.public.vsnet.ide)
  • Developing more than one .net site at a time under IIS 5.1 on XP Pro
    ... *Site* and not the root of the VirDir. ... than one application i need to have all my images in the site root's images ... all the image links in my entire site or copy the images directory to the ... cut down version isnt being used to host live websites to multiple users. ...
    (microsoft.public.inetserver.iis)
  • Developing more than one .net site at a time under IIS 5.1 on XP Pro
    ... *Site* and not the root of the VirDir. ... than one application i need to have all my images in the site root's images ... all the image links in my entire site or copy the images directory to the ... cut down version isnt being used to host live websites to multiple users. ...
    (microsoft.public.dotnet.framework.aspnet)