tags:

views:

393

answers:

2

Is there a javascript function to swap a still image(jpg) to a movie(swf)? If there is is there a disjointed swap image path?

+3  A: 

You could do something like this:

<div id="still_image" style="display:block">
    <!-- img code here -->
</div>


<div id="ani_swf" style="display:none">
    <!-- embedded swf here -->
</div>

<input type="button" value="Swap" onclick="imgToSWF();" />

<script type="text/javascript">

function imgToSWF() {
    document.getElementById('still_image').style.display = 'none';
    document.getElementById('ani_swf').style.display = 'block';
}

</script>
Jack
A: 

You can use swfobject. Ofcourse, you didn't said too much about what do you really want to do: on mouseover, on page load (and the image will be only a replacement), and so on...

Ionut Staicu