0
我使用能夠打印整個文件的內容行:閱讀txt文件通過線使用JavaScript
write(document.getElementById('iframe').contentDocument.body.firstChild.innerHTML);
但我怎麼用線檢索和打印文件內容系?
我使用能夠打印整個文件的內容行:閱讀txt文件通過線使用JavaScript
write(document.getElementById('iframe').contentDocument.body.firstChild.innerHTML);
但我怎麼用線檢索和打印文件內容系?
可以使用分裂功能和分隔符「\ r \ n」或「\ n」來提取您加載內容都各條線,然後再執行任何你想與他們做的事:
var text = document.getElementById('iframe').contentDocument.body.firstChild.innerHTML;
var lines = text.split("\n"); // this will extract all the lines
for (i=0; i<lines.length; i++) { // this will move over all the lines
var current_line = lines[i]; // this contains every line at its turn
// do here what ever you want to do with current_line
}
文件處理在JS中是不可能的,你在提問時需要具體說明.. –
我相信任何事情都是可能的,包括JS中的文件處理......我已經解決了我的問題! –