Solved

save content of a div

Posted on 2003-11-25
3
807 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now