|
|
Forum moderator: bigblog |
uCoz Community For Webmasters Custom Solutions Change image on click |
Change image on click |
I'm having problems with my script, he should work like this:
if $RFILE_DIRECT_URL$ is a image.gif then a image.jpg will appear instead, and when the image.jpg is clicked then the image.gif will appear instead of her. This is the script: Code html in apparences of entries <img src="/image.jpg" id="pic" onclick="change()"/> <img id="second" src="$RFILE_DIRECT_URL$" style="display:none;"/> <img id="first" src="/image.jpg" style="display:none;"/> js function change() { var imag = document.getElementById('pic').src; var img = imag.slice(-3); var img1 = document.getElementById('second').src; var imag2 = document.getElementById('first').src; if(img == 'gif') { document.getElementById('pic').src=imag2; } else { document.getElementById('pic').src=img1; } } I'm using that script in /load module - apparences of entries. He only works if $RFILE_DIRECT_URL$ is .gif, i'm using ucoz conditional operators for that. The script works now only on the first entry, how cand i make it work for all images ? If you dont' understand what this script should do, here is an example 9gag.com/gif . Added (2014-01-17, 11:57 AM) Code $ID$ If someone needs the working script, click here. |
| |||
| |||