(033)javascript_bom_documentWrite

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5     <title>BOM</title>
 6     <script type="text/javascript">
 7 
 8         window.onload = function() {
 9 
10             var myBtn = document.getElementById("myBtn");
11 
12             var myCodeText = document.getElementById("myCodeText");
13 
14             myBtn.onclick = function() {
15 
16                 var newWin = window.open("about:blank");
17 
18                 var value = myCodeText.value;
19 
20                 newWin.document.write(value);
21             };
22             
23         };
24         
25     </script>
26 </head>
27 
28 <body>
29     
30     <textarea id="myCodeText" rows="9" cols="30"></textarea>
31 
32     <input id="myBtn" type="button" value="run"/>
33 
34 </body>
35 </html>

 

posted @ 2014-03-23 10:30  雪中飞雁  阅读(83)  评论(0)    收藏  举报