0

me using asp.net mvc as technology behind. how can i use JavaScript for saving content of div "bla bla" as Txt or PDF Document on Client-side? something like this?? if yes, how can i do it? me not very strong in javascript :(

<div id="Overview">bla bla</div>
<input type="button" id="SaveAsTxt" onclick="JavaScript:SavePartOfPageAsTxt('Overview');"/></div>

 <script type="text/javascript">
<!--
        function SavePartOfPageAsTxt(elementId) {
        }
// -->
</script>
cweiske
  • 30,033
  • 14
  • 133
  • 194
r.r
  • 7,023
  • 28
  • 87
  • 129
  • Close duplicate of http://stackoverflow.com/questions/582268/read-write-to-file-using-jquery - the same applies for Javascript/jQuery. – Stuart Dobson Apr 23 '12 at 22:49

1 Answers1

1

Do you want to save the text file on the client or the server?

For saving to the server, use Javascript to send the data to the server code and use your server code to save it.

For saving to the client, you might have a problem getting access to the client's machine (and rightly so), however, you can do it with an ActiveX control or Flash (not ideal), or even save it as a cookie.

Another option if you wanted to use jQuery is this plugin: http://www.filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/ - this will ask the client if they're happy to save the file.

EDIT: Close duplicate of Read/write to file using jQuery - the same applies for Javascript/jQuery.

Community
  • 1
  • 1
Stuart Dobson
  • 3,001
  • 4
  • 35
  • 37