If I click on button javascript will be append to iframe.
example:
<button id="run">Click me!</button>
<textarea></textarea>
var iframe = here_is_iframe_object;
$('#run").click(function(e) {
$(iframe).find("script[id=myScript]").remove();
$(iframe).append("<script id='myScript'>"+ $("textarea").val() +"</script>");
});
If I put into the textarea setInterval with alert for example and after that put simple alert, it will be execute setInterval with alert and new alert at the same time.
setInterval(function() {
alert(true);
}, 5000);
How to stop previous javascript and execute only new code?
Thanks in advance.