寒莎

导航

如何将页面中的一段html代码赋给页面中的一个变量

<html>

<head>
<script>

   function openWindowTest(){
  window.open('test2.html','newwindow','height=100,width=400');
 }

       function check()
       {
      var te=document.getElementById("checkHtml").innerHTML;
      alert(te);
      document.getElementById("rr").value=te;
      }

</script>
</head>

<body>
<form name="testForm" action="" methed="GET">
<div id="checkHtml">
<table>
 <tr>
  <td>
   <input type="text" name="text1" value="1"/>
  </td>
  <td>
   <input type="text" name="text2" value="2"/>
  </td>
 </tr>
 <tr>
  <td>
   <input type="hidden" name="text3" value="3"/>
  </td>
  <td>
   <input type="hidden" name="text4" value="4"/>
  </td>
 </tr>
 <tr>
  <td>
   <input type="button" name="button1" value="dakai" onclick="openWindowTest()"/>
  </td>
  <td>
   <input type="submit" name="button2" value="tijiao"/>
  </td>
 </tr>
</table>
<div>
<input type="tt" name="wenshu" id="rr">
<input type="button" name="cc" onclick="check()"/>
</form>
</body>

</html>

posted on 2012-06-08 16:51  寒莎  阅读(466)  评论(0)    收藏  举报