<meta charset='utf-8'>
<textarea id='txt' rows='30' cols='110'></textarea>
<input type="button" id='btn' value="运行">
<script>
var btn = document.getElementById('btn'),
txt = document.getElementById('txt');
btn.onclick = function () {
//open是有返回值的,返回值就是新打开的窗口
var newPage = window.open('newPage');
//再往新窗口里写内容
newPage.document.write(txt.value);
}