PDA

View Full Version : Is it possible to use multiple "replace" functions?


A_Grant
12-06-2009, 03:51 AM
In simple, my goal is to have multiple scripts that replace what is in a div with what I have identified in my script. The code works fine if there is only one script in the page and one link that calls the script.

My plan is to have say 10 video posts on a page all with their own ajax script that holds the information for that particular video. The thumbnail for each particular post will be a link "<a href="javascript:replace">image</a>" to run the video in the video div without reloading the page.

Here is the code with one script and one link. It is fully functional. I am not trying to advertise, I just needed a RTMP stream to test.


<script type="text/javascript">
function replace() {
document.getElementById('video').innerHTML = "<embed src=\'http://player.longtailvideo.com/player.swf\' width=\'470\' height=\'290\' bgcolor=\'#ffffff\' allowscriptaccess=\'always\' allowfullscreen=\'true\' flashvars=\'file=AxiomRandy-iPhone.f4v&streamer=rtmp://fms.0811.edgecastcdn.net/000811/video_test&autostart=true\' />";
}
</script>


<p><a href="javascript:replace()">Let's See Randy</a></p>
<br /><br />

<div id="video">
<embed src='http://player.longtailvideo.com/player.swf' width='470' height='290' bgcolor='#ffffff' allowscriptaccess='always' allowfullscreen='true' flashvars='file=bunny.flv&streamer=rtmp://edge01.fms.dutchview.nl/botr' />


I guess my question is, can a "replace function" have a unique identifier that is only run by its unique link?



Thanks!