Hi,
so I was making this photo-gallery, and was using some javascript to make it look a little better, as in not having to refresh the entire page when you click on a thumbnail. I've gotten quite far with it, especially since most of it comes from google searches (I really don't know much about Javascript), but there is one thing that still isn't working, and that's the changing of the onclick value. Now I've read that this is known as a sticky situation, but I can't find a solution myself, and was hoping someone here could help me on.
This is the javascript-code:
[CODE=javascript]
<script language="javas cript" type="text/javascript">
function igGrow(id,imgst r,igw,igh,imgst r2,igw2,igh2)
{
var omg = document.getEle mentById(id);
omg.style.width = igw;
omg.style.heigh t = igh;
omg.style.backg roundImage = imgstr;
omg.onclick = Function('igShr ink("' + id + ',' + imgstr + ',' + igw + ',' + igh + ',' + imgstr2 + ',' + igw2 + ',' + igh2 + '")');
}
function igShrink(id,img str,igw,igh,img str2,igw2,igh2)
{
var omg = document.getEle mentById(id);
omg.style.width = igw2;
omg.style.heigh t = igh2;
omg.style.backg roundImage = imgstr2;
omg.onclick = Function('igGro w("' + id + ',' + imgstr + ',' + igw + ',' + igh + ',' + imgstr2 + ',' + igw2 + ',' + igh2 + '")');
}
</script>
[/CODE]
And this is how it looks like in the HTML:
[HTML]<a href="#x" onclick="igGrow ('imgid1','url( ./myrtle/1.jpg)','500px' ,'333px','url(./myrtle/tmb/1.jpg)','106px' ,'70px')" style="position :relative;displ ay:block;width: 106px;height:70 px;background-image:url(./myrtle/tmb/1.jpg)" id="imgid1" class="img"></a>[/HTML]
What it does now, is that when you click on a thumbnail, it enlarges into the image. What it's supposed to do also, but that part isn't working, is that when you click on the now larger image, it should make it smaller again.
You can still see an example online with my old code. But there you have to single click to open, and double click to close, and it uses all inline-javascript, making the filesize simply huge.
I would really appreciate all the help I could get.
Niels
so I was making this photo-gallery, and was using some javascript to make it look a little better, as in not having to refresh the entire page when you click on a thumbnail. I've gotten quite far with it, especially since most of it comes from google searches (I really don't know much about Javascript), but there is one thing that still isn't working, and that's the changing of the onclick value. Now I've read that this is known as a sticky situation, but I can't find a solution myself, and was hoping someone here could help me on.
This is the javascript-code:
[CODE=javascript]
<script language="javas cript" type="text/javascript">
function igGrow(id,imgst r,igw,igh,imgst r2,igw2,igh2)
{
var omg = document.getEle mentById(id);
omg.style.width = igw;
omg.style.heigh t = igh;
omg.style.backg roundImage = imgstr;
omg.onclick = Function('igShr ink("' + id + ',' + imgstr + ',' + igw + ',' + igh + ',' + imgstr2 + ',' + igw2 + ',' + igh2 + '")');
}
function igShrink(id,img str,igw,igh,img str2,igw2,igh2)
{
var omg = document.getEle mentById(id);
omg.style.width = igw2;
omg.style.heigh t = igh2;
omg.style.backg roundImage = imgstr2;
omg.onclick = Function('igGro w("' + id + ',' + imgstr + ',' + igw + ',' + igh + ',' + imgstr2 + ',' + igw2 + ',' + igh2 + '")');
}
</script>
[/CODE]
And this is how it looks like in the HTML:
[HTML]<a href="#x" onclick="igGrow ('imgid1','url( ./myrtle/1.jpg)','500px' ,'333px','url(./myrtle/tmb/1.jpg)','106px' ,'70px')" style="position :relative;displ ay:block;width: 106px;height:70 px;background-image:url(./myrtle/tmb/1.jpg)" id="imgid1" class="img"></a>[/HTML]
What it does now, is that when you click on a thumbnail, it enlarges into the image. What it's supposed to do also, but that part isn't working, is that when you click on the now larger image, it should make it smaller again.
You can still see an example online with my old code. But there you have to single click to open, and double click to close, and it uses all inline-javascript, making the filesize simply huge.
I would really appreciate all the help I could get.
Niels
Comment