Topic: Javascript Embedding Scripts onclick

Hi there, Apologies if in the wrong section. What I would like to do is change the content of a div based on the different links clicked on the same page. Can anyone point me in the correct direction? AFAIK it could be dangerous to insert scripts directly into a page, changing text works okay but it seems I'm not sure about scripts. The content of the scripts are embed codes for video streaming. I realise this may not be the right way to go about it. My attempt won't work because of escaping the '<,>' characters and passing the parameter only seems to accept text with no spaces.

The way I've attempted it is as follows (in pseudocode);
function changeVideo(script){ div.innerhtml=script;}

then links that change the content of the div;
<a href='#' onclick=changeVideo('<iframe etc..></iframe>')>link1</a>
<a href='#' onclick=changeVideo('<iframe etc..></iframe>')>link2</a>

Last edited by BrettCawley (2011-08-30 20:32:34)