I have made a playground
It takes HTML/CSS/JS from textareas and injects them into an Iframe. I had a problem in inserting JS.
I went to this site Inject Javascript from a textarea into an Iframe (my code is exactly the same from net tuts+) but I wasn't able to understand
Here is my code:
(function() {
$('.grid').height( $(window).height() );
var contents = $('iframe').contents(),
body = contents.find('body'),
styleTag = $('<style></style>').appendTo(contents.find('head')),
scriptTag = $('<script></script>').text($('.js').val()).appendTo(contents.find('head'));
$('textarea').keyup(function() {
var $this = $(this);
if ( $this.attr('id') === 'html') {
body.html( $this.val() );
}
if ( $this.attr('id') === 'css') {
styleTag.text( $this.val() );
}
});
})();
Can someone help me