日期:2014-05-16  浏览次数:20327 次

JS 保存文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script>
function   getValue(evt)
{
    var   ev=evt?evt:window.event;
    var   src=ev.srcElement?ev.srcElement:ev.target;
    if(src.tagName=="INPUT")
    {
        document.getElementById("SID").value=src.value;
    DefaultBG();
        src.parentNode.style.backgroundImage="url(bg2.gif)";
    }
    else   if(src.tagName=="TD")
    {
        document.getElementById("SID").value=src.getElementsByTagName("input")[0].value;
    DefaultBG();
        src.style.backgroundImage="url(bg2.gif)";
    }
}
function DefaultBG()
{
  var tb=document.getElementById("MyTb");
  for(var i=0;i<tb.rows.length;i++)
  {
     tb.rows[i].cells[0].style.backgroundImage="url(bg1.gif)";
  }
}
</script>
</head>
<body>

<table width="150" border="0" id="MyTb" cellspacing="0" cellpadding="0"   onmousedown="getValue(event)">  
  <tr>  
    <td height="25" background="bg1.gif">   <input name="txt1" type="text" id="txt1" size="10"   value="chinese">chinese   </td>  
  </tr>  
  <tr>  
    <td height="25" background="bg1.gif">   <input name="txt2" type="text" id="txt2" size="10" value="USA"> USA   </td>
  </tr>  
  <tr>  
    <td height="25" background="bg1.gif">   <input name="txt3" type="text" id="txt3" size="10" value="FR"> FR   </td>
  </tr>  
</table>  
select value:<input name="sID" type="text" id="SID" size="10">
<br><input type='button' value='save' onclick="document.execCommand('saveas','567','.txt')"/>
</body>
</html>