Hi. This script changes the image, I wanted to know if there is a way to automatically resize the div’s height and width based on the actual image proportions.
Thank you
[CODE]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta content=”text/html; charset=utf-8″ http-equiv=”Content-Type” />
<title>Switch Picture</title>
<script type=”text/javascript”>
function changeIt(imageName,objName)
{
var obj = document.getElementById(objName);
var imgTag = “<img src='”+imageName+”‘ width=’100%’ height=’100%’ border=’0′ />”;
obj.innerHTML = imgTag;
return;
}
</script>
</head>
<body>
<div id=”change” style=”[COLOR=”Red”]width:200px; height:200px;[/COLOR]”>
<img src=”cat.jpg” width=”100%” height=”100%” border=”0″ />
</div>
<br/>
<a href=”#” onclick=”changeIt(‘dog.jpg’,’change’);”>Switch to Dog Pic</a>
</body>
</html>