I am trying to change the source of an image. Works fine in IE but not in Firefox. Can anybody see what I am doing wrong?
The new image is loaded and then new dimensions (
width, height) are applied.
The code below can just be copied and pasted in your favourite editor:
<html>
<head>
<script type="text/javascript">
function SwapMe(ImageID)
{
var x = document.getElementById(ImageID);
x.attributes.src.value = ' ImageWidth = x.attributes.MyWidth.value;
ImageHeight = x.attributes.MyHeight.value;
x.attributes.width.value = ImageWidth;
x.attributes.height.value = ImageHeight;
}
</script>
</head>
<body>
<div onclick="SwapMe('Image1')">click me!</div>
<div id="imageholder001" name="imageholder001" class="imageholder001">
<img id="Image1" src=" MyWidth="1000" MyHeight="667" ContainingDiv="imageholder001" width="348px" height="80px" alt="my picture" title="title2" />
</div>
</body>
</html>
The new image is loaded and then new dimensions (
width, height) are applied.
The code below can just be copied and pasted in your favourite editor:
<html>
<head>
<script type="text/javascript">
function SwapMe(ImageID)
{
var x = document.getElementById(ImageID);
x.attributes.src.value = ' ImageWidth = x.attributes.MyWidth.value;
ImageHeight = x.attributes.MyHeight.value;
x.attributes.width.value = ImageWidth;
x.attributes.height.value = ImageHeight;
}
</script>
</head>
<body>
<div onclick="SwapMe('Image1')">click me!</div>
<div id="imageholder001" name="imageholder001" class="imageholder001">
<img id="Image1" src=" MyWidth="1000" MyHeight="667" ContainingDiv="imageholder001" width="348px" height="80px" alt="my picture" title="title2" />
</div>
</body>
</html>