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



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 - and a bit of time spent learning the difference between absolute & relative paths
.



Relevant Pages

  • Re: Relative paths break after install
    ... > When you install the product, you images should still be in the correct ... >> If my project has subfolders and I have relative paths into those folders ... the relative paths are different and nothing works. ... >> deployment wizard puts it there by default). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SSL Certificate
    ... It's not using relative paths, it's making sure the images are in the same folder. ... Make sure you use relative paths on images and not full urls or your viewers will get insecure errors. ...
    (microsoft.public.publisher.webdesign)
  • Re: OK Whatve I done?
    ... Sure you can edit everything in notepad, ... all the files so it can work with them using relative paths and the like and ... >> I don't know what has changed, but I have always import my images into ... >> FrontPage Resources, WebCircle, MS KB Quick Links, etc. ...
    (microsoft.public.frontpage.client)
  • Re: Picture on a form: Using a relative path
    ... Access doesn't work with relative paths: it will only allow full paths. ... > I have an access database for some paintings. ... > I can accomplish this if I use full path of the images in ImageDir field. ...
    (microsoft.public.access.forms)
  • Re: images not showing in Mozilla and Firefox
    ... link to that same page in my browser then my frame dont show the pictures ... relative paths not being correctly recognized, ... why...I believe my images relative path which is actually the same path ... clicking over a link then the frame dont render the pinctures but just ...
    (microsoft.public.dotnet.framework.aspnet)