sd*@bdgrp.com (Sybil) writes:
Could someone tell me what is wrong with this function?
In which browser?
function imageNext(){
if ( document.part.src == "images/returnAdapter.gif"){
The assumption that "document.part" refers to the element with name
"part", doesn't hold in all browsers. A safer way of referencing the
element is
document.images['part']
You compare the value of the src property to a releative path.
Most browsers (including IE6) changes to property to the absolute path.
E.g., if I create an image as:
<img src="../../PicA.png" id="foo">
and then read the src value again with javascript (in IE 6)
document.all.foo.src
the result is
"file:///D:/Home/lrn/html/PicA.png"
That means that your comparison will alway fail.
You should test that the src *ends* with your string, e.g., with a
regular expression:
if (/images\/returnAdapter.gid$/.test(document.images['part'].src) {
document.part.src = "images/valveIntake.gif";
Again, "document.imagesŲ is safer.
document.getElementById("c").style.color = "black";
document.getElementById("d").style.color = "red";
}
A "}" is missing here (just to be pedantic :)
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'