Solved

save content of a div

Posted on 2003-11-25
3
809 Views
Last Modified: 2012-08-13
hello is it possible to save only the content of a div with execCommand('SaveAs') ?
0
Comment
Question by:ferryl
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
jaysolomon earned 20 total points
ID: 9817933
you could try this

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function newWin(theDiv){
      var nw = window.open("","newWin");
      var docWrite = nw.document.write;
            docWrite('<html>\n<body>\n');
            docWrite('<script>document.write(opener.document.getElementById(\''+theDiv+'\').innerHTML)<\/script>\n');
            docWrite('<form name="form1">\n');
            docWrite('<input type="button" name="btn" value="Save As" onclick="document.execCommand(\'SaveAs\');">\n');
            docWrite('<\/form>\n');
            docWrite('<\/body>\n<\/html>');
}
// -->
</script>
</head>
<body>
<a href="#" onclick="newWin('myDiv');return false;">Save As</a>
<div id="myDiv">
      this is some content
      this is some content
      this is some content
      this is some content
</div>      
</body>
</html>
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10383689
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: jaysolomon {http:#9817933}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question