在博客中应用document.write方法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
window.onload=function(){
var oBtn=document.getElementById('btn1');
var oTxt=document.getElementById('txt1');
oBtn.onclick=function(){
var oNewWin=window.open('about:blank','_blank');
oNewWin.document.write(oTxt.value);
};
};

</script>
</head>

<body>
<textarea id="txt1" rows="10" cols="40">

</textarea><br/>
<input type="button" id="btn1" value="运行"/>

<!--<input type="button" value="打开窗口" onclick="window.open('../优酷整站实例-css/源码及素材/youku/youguili.html')"/>
<input type="button" value="write" onclick="document.write('abc')"/>
document.write结合事件来用,会先把页面上的内容清空了,再把write里面的内容写到页面-->
</body>
</html>

posted @ 2015-04-03 13:53  海泉  阅读(110)  评论(0编辑  收藏  举报