danielwarner
05-09-2007, 07:50 PM
To begin with, im a novice at this so the code probably can be more efficient or what ever but below is just what i have knocked out. The script is ment to enlarge the image by making the style width wider and the border smaller onmouseover and the same onmouseout (although i got stuck before managing to make the shrink function).
The code has a bug it in somewhere which is annoying me! The code isnt large so im assuming it should be easy to spot. I have run a few tests, the while works, the enlarge function works althogh the script doesnt process. I think it may have something to do with the setTimeOut and the input of the id's into the function. (i tried a few experiments and i dont think the '1','2'...etc have passed into the function.
Anyway, if anyone can help me then it would be much appreciated :thumbsup:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
#images {
background-color:#ccc;
padding:6px 3px;
text-align:center;
}
#images img {
width:120px;
height:120px;
border:8px solid white;
margin:0 3px;
}
</style>
<script type="text/javascript">
<!--Begin
function expand(imageID){
var width=120
var height=120
max=8
i=0
while(i<=max){
i++
max--
width++
height++
function change(){
document.getElementById('img-1').style.width=width+"px"
document.getElementById('img-1').style.height=height+"px"
document.getElementById('img-1').style.border=max+"px solid white"
}
var t=setTimeout("change()")",500)
}
}
//END-->
</script>
</head>
<body>
<div id="images">
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-1" onmouseover="expand('1')" onmouseout="shrink(1)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-2" onmouseover="expand('2')" onmouseout="shrink(2)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-3" onmouseover="expand('3')" onmouseout="shrink(3)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-4" onmouseover="expand('4')" onmouseout="shrink(4)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-5" onmouseover="expand('5')" onmouseout="shrink(5)"/>
</div>
<div id="text"></div>
</body>
</html>
This code should run straight off if you want to test it.
The code has a bug it in somewhere which is annoying me! The code isnt large so im assuming it should be easy to spot. I have run a few tests, the while works, the enlarge function works althogh the script doesnt process. I think it may have something to do with the setTimeOut and the input of the id's into the function. (i tried a few experiments and i dont think the '1','2'...etc have passed into the function.
Anyway, if anyone can help me then it would be much appreciated :thumbsup:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
#images {
background-color:#ccc;
padding:6px 3px;
text-align:center;
}
#images img {
width:120px;
height:120px;
border:8px solid white;
margin:0 3px;
}
</style>
<script type="text/javascript">
<!--Begin
function expand(imageID){
var width=120
var height=120
max=8
i=0
while(i<=max){
i++
max--
width++
height++
function change(){
document.getElementById('img-1').style.width=width+"px"
document.getElementById('img-1').style.height=height+"px"
document.getElementById('img-1').style.border=max+"px solid white"
}
var t=setTimeout("change()")",500)
}
}
//END-->
</script>
</head>
<body>
<div id="images">
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-1" onmouseover="expand('1')" onmouseout="shrink(1)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-2" onmouseover="expand('2')" onmouseout="shrink(2)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-3" onmouseover="expand('3')" onmouseout="shrink(3)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-4" onmouseover="expand('4')" onmouseout="shrink(4)"/>
<img src="http://www.hermann-uwe.de/files/images/blue_flower.preview_0.jpg"
id="img-5" onmouseover="expand('5')" onmouseout="shrink(5)"/>
</div>
<div id="text"></div>
</body>
</html>
This code should run straight off if you want to test it.