2014-03-25 30 views

回答

-1

不,JavaScript無權訪問寫入文件,因爲這會帶來巨大的安全風險。

看到Read/write to file using jQuery

如果你想簡單地使用jQuery這是非常簡單的下載內容,並在腳本中使用它, :

https://api.jquery.com/jQuery.ajax/

jQuery.ajax({ 
    url: "your/file/here", 
    dataType: 'text', // you can also use xml, json, html here 
    success : function(data) { 
     console.log(data); 
    }, 
    error : function(xhr, textStatus, errorThrown) { 
     console.log("ERROR: "+textStatus+", "+errorThrown); 
    }, 
    async: true 
}); 
+0

我做了使用jquery。現在我需要下載,而不會顯示給用戶指定的位置 – user3318686

+0

您對「指定位置」有什麼意義?寫入文件系統?這不適用於JavaScript(見上文)。 – ivicaa