I'm running into a problem trying to copy the values of some hidden variables to the clipboard. I'm trying to implement the solution seen here:
http://www.jeffothy.com/weblog/clipboard-copy/
The only problem is that I don't know how to then call this function to copy the values of some hidden variables. I created a HTML region that displays after the header with the following:
<script type="text/javascript">
function copy(inElement)
{
if (inElement.createTextRange)
{
var range = inElement.createTextRange();
if (range && BodyLoaded==1)
range.execCommand('Copy');
}
else
{
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier))
{
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '<embed src="& C_SYSIMG_PATH._clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
document.getElementById(flashcopier).innerHTML = divinfo;
}
}
</script>
I then created a Display As Text item and used the following for it's source value:
a href="javascript:copy(&P2911_TITLE.);" COPY POSTING TITLE! /a
(I know the preceding line isn't a valid a href tag, but it wouldn't let me include the greater than and less than signs without making an actual link, even though I'm putting it all between pre and /pre tags)
I thought that's all I would have to do, and that by clicking on this link, it would copy the value of P2911_TITLE to the clipboard, but instead it doesn't do anything. Any thoughts? I even tried creating a button and calling the function through onclick, but that didn't work either. Really have no clue as to why this isn't working. Anyone? Thanks!