Re: Simple image swap not working...Why?
- From: Ed Jay <edMbj@xxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 22:38:34 -0700
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)
.
- References:
- Simple image swap not working...Why?
- From: Ed Jay
- Re: Simple image swap not working...Why?
- From: VK
- Re: Simple image swap not working...Why?
- From: Ed Jay
- Re: Simple image swap not working...Why?
- From: Tony
- Simple image swap not working...Why?
- Prev by Date: Re: Creating a new Explorer Window by passing HTML
- Next by Date: Re: Problem with window.open
- Previous by thread: Re: Simple image swap not working...Why?
- Next by thread: Create DOM object holding an external page
- Index(es):
Relevant Pages
|