Preview with 3 editor

Sorry for my English. How to make preview with 3 editors, html, css and JS? I have problem with js because, code is insert to < head > iframe but not working.
code function `

function updatePreview() {

var previewFrame = document.getElementById('preview');
var preview =  previewFrame.contentDocument ;;

$("#preview").contents().find("head").html('<script type="text/javascript">'+AreaJS.getValue()+'</script>');
$("#preview").contents().find("head").html('<style type="text/css">'+AreaCSS.getValue()+'</style>');

setTimeout(updatePreview, 300);