0
function createTable(){
var _table = document.getElementById("test");
var newRow = _table.insertRow(1);
var cell0 = newRow.insertCell(0);
var cell1 = newRow.insertCell(1);
cell0.innerHTML = "x";
cell1.innerHTML = 60;
}
function saveTable(){
document.execCommand("saveas",,"/tmp/test.html");
}
<p>to create my table</p>
<input type="button" value="to create new table" onclick="createTable()" />
<input type="button" value="to save table as /tmp/test.html" oncilck="saveTable()" />
<table id="test" bodrder=1px>
<tr>
<td>f1</td>
<td>f2</td>
</tr>
</table>
當表是由函數創建CREATETABLE,我希望得到一個文件/tmp/test.html,其內容如下
<table id="test">
<tr>
<td>f1</td>
<td>f2</td>
</tr>
<tr>
<td>x</td>
<td>60</td>
</tr>
</table>
如何履行我的saveTable功能來完成這項工作?
兩個問題遺蹟。 –
1.位置保存文件 –
我想要的是'/ tmp/test.html',我得到的代碼是'/ Downloads/_tmp_test.html' –