Add events to tinyMCE window - Add events to iframe content

From Code Trash
Jump to: navigation, search
<script>
var ketim = null;
window.onload = function()
{
	ketim = window.setTimeout('setkeyevent()',1000);
}
 
function setkeyevent()
{
 
	if(!window.frames.length) return;
	clearInterval(ketim);
 
	if(window.addEventListener)
	{	
		window.frames[0].window.document.addEventListener('keypress',function(){
			alert(document.getElementById('bodycont').innerHTML)
			document.getElementById('bodycont').innerHTML='';
		},false)
	}	
	else if(window.attachEvent)
	{	
		window.document.frames[0].window.document.attachEvent('onkeypress',function(){
			document.getElementById('bodycont').innerHTML='';
		})
	}
}
</script>