T
Tim Streater
I have a small image on my web page that, when clicked, does some
javascript stuff which changes the page. To highlight that this has
happened, I want to replace the image with another. Each is a 16x16
pixel image.
The images are pre-loaded:
var image_g = new Image (16, 16);
var image_r = new Image (16, 16);
image_g.src = 'pics/arrow-g.jpg';
image_r.src = 'pics/arrow-r.jpg';
Then later when the user clicks on the image, I do (e.g.) this:
document.getElementById('pixie').src = image_g.src;
where pixie is an <img> in an <a href> in a table cell.
This works fine in Safari, IE (Mac and XP), Netscape 7 (XP), and FireFox
2.0.0.1 (Mac). However it does not work in Netscape 6 (XP) and FireFox
2.0 (XP). The behaviour is as if the statement were commented out - I
get no Javascript errors, but the statement is ignored.
Am I somehow missing something which would make this completely standard
JS? Any clues appreciated.
Thanks,
-- tim
javascript stuff which changes the page. To highlight that this has
happened, I want to replace the image with another. Each is a 16x16
pixel image.
The images are pre-loaded:
var image_g = new Image (16, 16);
var image_r = new Image (16, 16);
image_g.src = 'pics/arrow-g.jpg';
image_r.src = 'pics/arrow-r.jpg';
Then later when the user clicks on the image, I do (e.g.) this:
document.getElementById('pixie').src = image_g.src;
where pixie is an <img> in an <a href> in a table cell.
This works fine in Safari, IE (Mac and XP), Netscape 7 (XP), and FireFox
2.0.0.1 (Mac). However it does not work in Netscape 6 (XP) and FireFox
2.0 (XP). The behaviour is as if the statement were commented out - I
get no Javascript errors, but the statement is ignored.
Am I somehow missing something which would make this completely standard
JS? Any clues appreciated.
Thanks,
-- tim