;);txt+= \" A & lt;br >;;}//var?元素?=?document . createelement(' a ');//將文本寫入element.setAttribute('href '," />
當前位置:編程學習大全網 - 編程軟體 - js如何將document.write的輸出保存為txt?

js如何將document.write的輸出保存為txt?

妳可以用

特定代碼:

& lt腳本& gt

var?txt?=?"";

for(var?I = 0;我& lt5;i++){

document . write(" A & lt;br >;);

txt+= " A & lt;br >;;

}

//

var?元素?=?document . createelement(' a ');

//將文本寫入

element.setAttribute('href ',?數據:文本/純文本;charset=utf-8,'?+?encodeURIComponent(txt));

//設置要另存為的名稱。

element.setAttribute('download ',?“結果”);

element.style.display?=?“無”;

document.body.appendChild(元素);

element . click();

document . body . remove child(element);

& lt/script & gt;

快樂編程。如果有用,請點擊采納。謝謝妳。

  • 上一篇:後模加工都有哪些內容要特別註意呢?
  • 下一篇:楚雄java培訓學校告訴妳安卓與java軟件開發區別大嗎?
  • copyright 2024編程學習大全網