Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving locally through the browser?

Posted on 2002-03-06
12
Medium Priority
?
185 Views
Last Modified: 2011-09-20
Greetings,

What I currently have is a XML editor in browser. I wish to do is allow the user to save the XML file to their local machine. Does anyone know how or if this is possible?

TIA

MistaBiggz
0
Comment
Question by:MistaBiggz
12 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6845031
They can save the html page.  They can cut and paste to a text file or they can download a file from the server and save it.  If they are editing a file form the server, then it has to be saved back to the server and then they can download it.  

I think that about covers the options, unless there is activex or a plugin involved.

Cd&
0
 

Author Comment

by:MistaBiggz
ID: 6845156
I'm utilizing servlets and JavaBeans in this application so I can save the file to the server. Is there a way to instantiate the "Save to Disk" dialogue without having the user click on a link to the file on the server?
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6845235
Not really. You want them to save it, there has to be a link of some kind or they need to have the page open.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6845597
Unfortunately, there is no way to do any sort of binding across the pages.  So you will have to come back with the link so they can do a conventional save. Once the browser sends the save to the server is becomes dumb until the server sends back something for it to process.

Cd&
0
 
LVL 3

Expert Comment

by:malcx
ID: 6846721
Use a signed applet or activeX controls to save to a local disk on the users machine.
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6850806
    <html>
          <head>
               <script language=vbscript>
                    sub download
                         set vDoc = createobject("Scripting.FileSystemObject")
                         set vStream = vDoc.CreateTextFile ("c:\test.xml")
                         set vframe = window.document.all("myframe")
                             
                         vStream.write vFrame.contentwindow.document.body.innertext
                             
                         
         
                    end sub
               </script>
          </head>
         
          <body>
               <a href="#" onclick="Download()">to the xml file</a>
               
               <iframe name=myframe id=myframe src="test.xml"></iframe>
          </body>
     </html>



This page does not do what you want completely, but it might be worth looking at ...

On my machine it saves the content of test.xml to a file c:\test.xml.  It says that it's unsafe (due to the filescripting object).  

So, this might help you on your way, but it's only for IE 5 and you must have the FileSystemObject installed.
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6850882
sub download
     set vDoc = createobject("Scripting.FileSystemObject")
     set vStream = vDoc.CreateTextFile ("c:\test.xml")
     set vframe = window.document.all("myframe")
                             
     vText = vFrame.contentwindow.document.body.innertext
                         
     vText = mid(vText, 3)
     vPos = 1
                         
     do
          vPos = instr(vPos + 3, vText, chr(10))
                             
          if vPos > 0 then
               vText = left(vText, vPos - 2) & vbcrlf & mid(vText, vPos + 3)
          end if
     loop until vPos = 0
                         
     vStream.write vText
end sub


This script is better  :-))
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 800 total points
ID: 6854865
clientside:

- Create an iframe:
<iframe name="fHidden" style="position:absolute;visibility:hidden;" src="about:blank"></iframe>

- add following script and call whenever necessary
<script>
function saveContent(sText, sDestination)
{
    if(document.layers) return false;
    document.frames[sDestination"].document.body.innerHTML = sText;
    document.frames[sDestination"].document.execCommand("SaveAs");
   return true;
}
</script>

- Call it like:
saveContent("<xml version=......><...>", "fHidden");
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6892547
Is this completed, or is more needed?

Cd&

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6975489
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6990031
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to CJ_S

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6990713
Comment from expert accepted as answer.

Computer101
E-E Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

916 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