js保存文件

function importNO()

  var win=window.open('','','height=10, width=10, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
  tel=document.sendForm.telNo.value ;
  tel=tel.replace(/\r\n/g,'<br>');

  win.document.write(tel)
  document.execCommand('SaveAs','','號碼備份.txt')
  win.close();
}

例1:
    isNaN是測試是否爲數值型 ,限制輸入只能爲數值如:1981.121,允許最多有一個小數點</pre>
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><input type="text" name="text" οnkeyup="if(isNaN(value))execCommand('undo')" /></div>
<pre>
例2:</pre>
<div>
<input type=button value=剪切 οnclick=document.execCommand('Cut')>
<input type=button value=拷貝 οnclick=document.execCommand('Copy')>
<input type=button value=粘貼 οnclick=document.execCommand('Paste')>
<input type=button value=撤消 οnclick=document.execCommand('Undo')>
<input type=button value=重做 οnclick=document.execCommand('Redo') id=button2 name=button2>
<input type=button value=刪除 οnclick=document.execCommand('Delete')>
<input type=button value=黑體 οnclick=document.execCommand('Bold')>
<input type=button value=斜體 οnclick=document.execCommand('Italic')>
<input type=button value=下劃線 οnclick=document.execCommand('Underline')>
<input type=button value=停止 οnclick=document.execCommand('stop')>
<input type=button value=保存 οnclick=document.execCommand('SaveAs')>
<input type=button value=另存爲 οnclick=document.execCommand('Saveas',false,'c:\\test.htm')>
<input type=button value=字體 οnclick=document.execCommand('FontName',false,fn)>
<input type=button value=字體大小 οnclick=document.execCommand('FontSize',false,fs)>
<input type=button value=刷新 οnclick=document.execCommand('refresh',false,0)></div>
<pre>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章