JS代码在线运行

<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);
}

猜你喜欢

转载自blog.51cto.com/11123779/2160295
今日推荐